Path: utzoo!utgpu!water!watmath!rbutterworth From: rbutterworth@watmath.waterloo.edu (Ray Butterworth) Newsgroups: comp.std.c Subject: Re: enums Message-ID: <20131@watmath.waterloo.edu> Date: 28 Jul 88 14:16:46 GMT References: <1608@dataio.Data-IO.COM> <5514@haddock.ISC.COM> Organization: U of Waterloo, Ontario Lines: 25 In article <5514@haddock.ISC.COM>, karl@haddock.ISC.COM (Karl Heuer) writes: > In article <1608@dataio.Data-IO.COM> bright@Data-IO.COM (Walter Bright) writes: > >[ANSI C seems not to allow:] > > enum abc { }; /* empty member list */ > > enum def { b, }; /* trailing comma */ > > 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.) Exactly. It's been pointed out before that if enums with no values were allowed, one could simply use: #typedef enum {} void; and not need void as part of the language. It would then be obvious why any other pointer could be cast to a (void*) since obviously (void*) needs the finest resolution, and it would be obvious why trying to subscript a void* would be useless (vs[7] would have a size of 7*sizeof(void) which is 7*0), and why a function returning void doesn't really return anything, or rather that what it returns is something that was already known before the function was called and one can't do anything with it anyway.