>> >Can someone pls tell me if it is possible to define an array of size 0.
>> 
>> Not in C.
>
>GCC and most other compilers support it. 
>I do it all the time (see all the various netgraph structures) however it must 
>be the LAST item in the structure. It gives the address of the first byte 
>AFTER the structure. This is very useful if the structure is a header of some
>sort.

While I prefer the 0-element method too, the ANSI standard doesn't allow it.

Fortunately there is a portable way to get the same effect.

Just put a 1-element array at the end of your header struct, and account for
it when you work out how much extra space to allocate. C memory layout rules
guarantee that this usage will have the desired effect.

Todd Whitesel
toddpw @ best.com

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to