Date: Thu, 29 Mar 2001 22:47:55 -0800 (PST) From: Todd Whitesel <toddpw@best.com> To: julian@elischer.org (Julian Elischer) Cc: seebs@plethora.net, tech-kern@netbsd.org, freebsd-hackers@freebsd.org Subject: Re: Question regarding the array of size 0. Message-ID: <200103300647.WAA25263@shell17.ba.best.com> In-Reply-To: <3AB87A5A.69562D89@elischer.org> from Julian Elischer at "Mar 21, 1 01:54:34 am"
next in thread | previous in thread | raw e-mail | index | archive | help
>> >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 majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103300647.WAA25263>