On 12/15/2010 08:15 PM, Aaron Plattner wrote:
> $ gcc test.c
> test.c: In function ‘main’:
> test.c:11: warning: initialization from incompatible pointer type
> $ ./a.out
> x
> $ gcc -O2 test.c
> test.c: In function ‘main’:
> test.c:11: warning: initialization from incompatible pointer type
> $ ./a.out
> a
>
Indeedubitably.
But what does it show? It shows you can shoot yourself in the foot, with
cheering applause from the compiler. No news here.
Something more to the point:
void callmeconst(const char * const * arg) {
printf("%s\n", *arg);
}
void main(void) {
char* cp = "s";
char** pp = &cp;
callmeconst(pp);
callmeconst(&cp);
}
yielding
warning: passing argument 1 of ‘callmeconst’ from incompatible pointer type
note: expected ‘const char * const*’ but argument is of type ‘char **’
times two but as least it doesn't fail to compile. Sure, you'd have to
wait for the standard to catch up or something equally desirable to get
rid of the warning, but I think it's a not-too-remote option.
Cheers,
Simon
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel