I know about the char **
vs const char **
thing (like described in the c faq) but I can't see any scenario where doing so with a pointer to arrays would lead to some content inside the arrays themselves being actually modified.
My code:
void fun(const char (*p)[6])
{
printf("%s", p[0]);
}
int main(int argc, char *argv[])
{
char a[6] = "hello";
char (*c)[6];
c = &a;
fun(c);
}
gives the below output when compiled with gcc:
test.c:17:9: warning: passing argument 1 of 'fun' from incompatible pointer type
test.c:5:10: note: expected 'const char (*)[6]' but argument is of type 'char (*)[6]'
The question here is somehow related but has no answer so far. Is it just the compiler being paranoïd and the only way to get rid of the warning is to explicitly cast ? Or is there really a chance something can go wrong ?