Zero Length Arrays Allowed in C Standard?

Bret Orsburn bret at codonics.COM
Sat Dec 9 07:27:26 AEST 1989


In article <7349 at quick.COM> srg at quick.COM (Spencer Garrett) writes:
>How would you deal with the following?
>
>	struct blat {
>		struct blat    *next;
>		int		value;
>		char		name[0];
>	} *new;
>If you
>declare it "char name[1]" then there's no portable way to get the
>size of the header (since you can't predict how much padding may
>need to be added).

Sorry if I am missing some subtlety here, (if so, I have probably edited
out the meat of it) but it seems pretty clear to me that the padding bytes
should exist in the zero-length case as well. Otherwise, the array "name"
is not legally aligned.

--
rn:
go
away
-- 
-------------------
bret at codonics.com
uunet!codonics!bret
Bret Orsburn



More information about the Comp.lang.c mailing list