Reputation: 3071
I have seen multiple questions (this one, for example) on this subject, but none explain the precise behavior I am seeing.
I have two functions, each declared and defined as such:
void PntCreate(Handle *cv);
void PntCreate(Handle * const cv)
{
//...
}
ErrorCodes wim2Read(const char *fileName, cdCanvas *cv,
int onViewport);
ErrorCodes wim2Read(const char * const fileName, cdCanvas * const cv,
const int onViewport)
{
//...
}
The declarations and definitions change only the const
qualifiers. From the question linked above, I understand that can lead to warnings since they don't match perfectly. However, what I find curious is that the warning only appear for PntCreate
, but not for wim2Read
.
What is happening here? I thought it might be because the argument of PntCreate
is a struct, but so is the second argument of wim2Read
...
Upvotes: 0
Views: 454
Reputation: 11377
Your problem is that cv in the definition of wim2Read is a pointer to Canvas instead of a pointer to cdCanvas. The const
in both PntCreate and wim2Read has no effect on the contract between the caller and the implementation since parameters are passed by value.
Upvotes: 1