Re: Warning for incompatible pointer type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux