Re: Warning when using const pointer to fixed size array

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

 



John (Eljay) Love-Jensen wrote:
> Hi Aaron,
> 
>> void foo(const int (* p)[9]);
>>
>> In this case, you are guaranteed that the caller is giving you a valid
>> buffer. Otherwise, you will get a compile error message which will help
>> you quickly detect a problem.
> 
> I think...
> 
> In C, arrays degenerate into pointers at the drop of a hat.
> 
> These two kinds of pointers are compatible:
> int* p;
> int const* p;
> 
> The two kinds of pointers are compatible:
> int** p;
> int* const* p;
> 
> The two kinds of pointers are not compatible:
> int** p;
> int const** p;
> 
> Your situation is like the third case.  The const is not
> two-levels-of-indirection compatible.
> 
> Anyone have ISO 9899 on hand to cite chapter & verse?

I just did.  :-)

Andrew.

[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