enums

Marco Franzen franzen at infbs.UUCP
Wed Aug 3 04:42:29 AEST 1988


In article <5514 at haddock.ISC.COM>, karl at haddock.ISC.COM (Karl Heuer) writes:
> I can see why one might want to allow the trailing comma, but what good is an
> enum with no values?  I think this is almost in the same category as
> zero-sized objects.  (I.e., the rule that allows small-valued enums to be
> stored in a char could be logically extended to allow non-valued enums to be
> stored in a zero-size type.)

Even a one-valued enum can be stored in a zero-sized type (i.e. ld 1
bits, calculate ld 0 and enjoy the storage you win :-).  You can get
an Algol68ish void with:

typedef enum { EMPTY } VOID;	/* EMPTY is the only value of type VOID */

But then there is no guarantee for sizeof(VOID)==0, not even for
sizeof(VOID)<=sizeof(char). (In this enum {} wouldn't be better, you
only needn't become Algol68ish.)



More information about the Comp.std.c mailing list