Re: Strange const warning

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

 



Ian Lance Taylor wrote:
> 
> This is a generic C question, not a question specific to gcc.
> 
> The reason is that when arrays are passed as parameters, they decay to
> pointers.  The effect is that the const qualifer does not work as you
> expect it to.

Thanks for the replies, you are right the function is being treated
something like:
	void test(int (*a)[1])

What's slightly strange is that if I make the array in main() const it
compiles without the warning.

Obviously removing the const in the test() argument is ok, it's a pity
you can't mark a multi-dimensional array parameter as const, it's just
part of the leagacy of C's pointer/array loose definition.

Jon


[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