apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Hudson <ghud...@MIT.EDU>
Subject Re: [PATCH] apr_getopt_long interface update and interleaving support
Date Sat, 25 Nov 2000 00:50:34 GMT
>> It wasn't "const char *const *argv" before because a "char **"
>> argument is not compatible with such a parameter, and C programs
>> canonically take "char **argv", not "const char *const *argv".  I'm
>> not sure if it's even valid C to silently change from char * to const
>> char * without an explicit cast, which is what you'd be doing if you
>> wrote a main() which accepted a list of const char pointers intead of
>> a list of char pointers.

> Don't be silly, you can always pass a non-const value for a const
> arg.  Same with silent promotions of int to long, etc.

The compiler can only promote the top-level parameter, not the
contents of an array.  Observe:

equal-rites% cat test.c
void foo(const char *const *a) { ; }
void bar() { char **b = 0; foo(b); }
equal-rites% gcc -c -Wall test.c
test.c: In function `bar':
test.c:2: warning: passing arg 1 of `foo' from incompatible pointer type


Mime
View raw message