Subject: Re: Question regarding the array of size 0.
To: Julian Elischer <email@example.com>
From: Todd Whitesel <firstname.lastname@example.org>
Date: 03/29/2001 22:47:55
>> >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
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.
toddpw @ best.com