Newsgroups: comp.std.c
Path: utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!hugh
From: hugh@dgp.toronto.edu ("D. Hugh Redelmeier")
Subject: Re: enums
Message-ID: <8807242307.AA27481@explorer.dgp.toronto.edu>
Organization: University of Toronto, CSRI
References: <1608@dataio.Data-IO.COM>
Date: Sun, 24 Jul 88 17:47:14 EDT

In article <1608@dataio.Data-IO.COM> bright@Data-IO.COM (Walter Bright) writes:
>From reading the grammar for enums in the Ansi spec, it seems that the
>following is not allowed:
>
>	enum abc { };		/* empty member list	*/
>	enum def { b, };	/* trailing comma	*/
>
>Many compilers accept this, and I've run across code that uses it. Any
>thoughts? Is this an oversight in the spec?

I submitted a comment on the trailing comma during the first public
review period.  So it isn't an oversight, but I do think that it is
a mistake.  I am not sure how I feel about empty enums (perhaps a
good definition for void might be: "typedef void enum {};" :-).
Here is my comment:

Section 3.5.2.3, page 54, line 17 [of the then-current draft]

I think that an enumerator-list should be optionally terminated by a
comma.  This is analogous to the way an initializer is optionally
terminated by a comma (3.5.6 61@21).  The benefits are similar (a
terminator is less error-prone than a separator (consider Pascal's
semicolon)).

This is currently legal in the two compilers I use (the Ritchie
compiler (the original implementation of enum, so it should carry
some weight), and System V VAX UNIX PCC).  I do use the feature.

Hugh Redelmeier
{utcsri, utzoo, yunexus, hcr}!redvax!hugh
In desperation: hugh@csri.toronto.edu
+1 416 482 8253

