🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5259

enums

#5259
From: Marco Franzen
Date: Tue, 02 Aug 1988 18:42
16 lines
1268 bytes
In article <5514@haddock.ISC.COM>, karl@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.)
Technical Details
Message-ID: <955@infbs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!mcvax!unido!infbs!franzen
References: <5514@haddock.ISC.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!mcvax!unido!infbs!franzen
From: franzen@infbs.UUCP (Marco Franzen)
Newsgroups: comp.std.c
Subject: enums
Summary: in Algol68 void has *one* value
Keywords: void, enum, algol68, empty
Message-ID: <955@infbs.UUCP>
Date: 2 Aug 88 18:42:29 GMT
References: <5514@haddock.ISC.COM>
Reply-To: franzen@dbsinf6.BITNET (Marco Franzen)
Organization: TU Braunschweig,Informatik,West Germany
Lines: 16