This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Warning for incompatible pointer type


2011/3/29 José Luis García Pallero:
> Hello,
> In the function bellow I pass two const pointers to a function. One
> pointer to a char** and the other to char*. When I compiling the
> program via gcc test.c -o test I obtain a warning:
>
> test.c:18:5: warning: passing argument 1 of ‘foo’ from incompatible pointer type
> test.c:4:6: note: expected ‘const char **’ but argument is of type ‘char **’
>
> What is the reason for the warning? I won't change the char** argument
> in the function so I think that declare it as const is correct. What
> the argument const char* do no emits a warning? I tested the program
> with gcc 4.5.2 and 4.6.0 and I obtain the warning in each compiler.

See the C++ FAQ Lite (this question applies to both C and C++):

http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.17


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]