Subject: Re: Question regarding the array of size 0.
To: Alfred Perlstein <>
From: Harti Brandt <>
List: tech-kern
Date: 03/30/2001 10:04:45
On Thu, 29 Mar 2001, Alfred Perlstein wrote:

AP>* Peter Seebach <> [010329 23:49] wrote:
AP>> In message <>, Todd Whitesel writes:
AP>> >Just put a 1-element array at the end of your header struct, and account for
AP>> >it when you work out how much extra space to allocate. C memory layout rules
AP>> >guarantee that this usage will have the desired effect.
AP>> Nope, not portable.  The implementation is allowed to bust you for
AP>> overstepping the bounds of the array.  :)
AP>> The only portable solution is the new feature in C99.
AP>Which new feature?

struct foo {
	double	bar;
	int	baz[];

I suppose. But neither gcc nor Sun-cc seem to support it :-(

# gcc -c x.c
x.c:3: field `baz' has incomplete type

# cc -c x.c
"x.c", line 3: null dimension: baz
cc: acomp failed for x.c

Well, that's even lesser portability.

struct foo {
	double	bar;
	int	baz[0];

works for both compilers.
harti brandt,