Possible Duplicate:
Double pointer const-correctness warnings in C
Look at the table here: http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html
We see that the following is invalid in C:
void f(const char * const argv[])
{
(void)argv;
}
int main(int argc, char *argv[])
{
(void)argc;
f(argv);
return 0;
}
test.c: In function 'main':
test.c:9: warning: passing argument 1 of 'f' from incompatible pointer type
test.c:1: note: expected 'const char * const*' but argument is of type 'char **'
Why is this invalid? It seems to me that const char * const argv[]
is just "more constant" than char * argv []
, (and it's allowed in C++) so why is it invalid in C?