Friday, 6 September 2013

Inconsistent warnings of type "Incompatible pointer types"

Inconsistent warnings of type "Incompatible pointer types"

My XCode (default compiler should be clang?) shows me on this code a warning:
Incompatible pointer types passing 'char *(*)[10]' to parameter of type
'char ***' (when calling func)
void func (char ***arrayref, register size_t size) {
/// ...
}
int main()
{
char *array[2] = {"string", "value"};
func(&array, 2);
}
while this code is no problem:
void func (char **arrayref, register size_t size) {
/// ...
}
int main()
{
char *array[2] = {"string", "value"};
func(array, 2);
}
While this removes the warning
func((char***)&array, 2);
I still don't know why the first emits a warning, while the latter doesn't.
Also, when the first is a problem, I'd also expect that the first emits a
warning like:
Incompatible pointer types passing 'char *[10]' to parameter of type 'char
**'

No comments:

Post a Comment