enum, no trailing comma?

Michael Meissner meissner at osf.org
Tue Aug 21 00:03:13 AEST 1990


In article <8 at christmas.UUCP> rtm at christmas.UUCP (Richard Minner)
writes:

| Is it just my eyes or does:
| 
| (From December 7, 1988 DRAFT)
| 3.5.2.2 Enumeration specifiers
| 
| Syntax
| 	<enum-specifier>:
| 		enum <identifier>_opt { <enumerator-list> }
| 		enum <identifier>
| 
| 	<enumerator-list>:
| 		<enumerator>
| 		<enumerator-list>, <enumerator>
| 
| 	<enumerator>:
| 		<enumeration-constant>
| 		<enumeration-constant> = <constant-expression>
| 		
| mean that a trailing comma:
| 	enum foo { one, two, three, };
| is disallowed?

Yes, trailing commas are not allowed for enum lists.

| If it really is disallowed, why?  It seems out of place, since
| trailing commas are ok in array and struct initializers.  Why so
| nitpicky here?  (gcc ignores the trailing comma unless you
| specify -pedantic.)  Are compiler vendors likely to consider such
| a comma a real live syntax error?  I suppose they have to.
| (Maybe it was just too hard to specify the syntax to allow a
| trailing comma? :-)

The original implementation of enum's also required a comma (or least
the documentation did not document that missing commas were allow, and
I don't have the source on-line), and ANSI reflects that.  My
recollection is it came up, but there was not enough sentiment to add
it.
--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?



More information about the Comp.std.c mailing list