Hi,
Is the extra comma at the end of an enumerator-list valid according to
the C standards?
With the gcc compiler the following is valid:
enum DAYS {MONDAY, TUESDAY, }day1;
gcc does not even *warn* about the extra comma after "TUESDAY".
I found references which say that this is valid in C99 standard but
invalid in C89. Please help me confirm on this.
Is this compiler specific behavior?
I also include the Backus-Naur form of C syntax for enum:
<type-specifier> ::= void
| char
| short
| int
| long
| float
| double
| signed
| unsigned
| <struct-or-union-specifier>
| <enum-specifier>
| <typedef-name>
<enum-specifier> ::= enum <identifier> { <enumerator-list> }
| enum { <enumerator-list> }
| enum <identifier>
<enumerator-list> ::= <enumerator>
| <enumerator-list> , <enumerator>
<enumerator> ::= <identifier>
| <identifier> = <constant-expression>
The above does grammar does not indicate that there could be a extra
comma at the end of an enumerator-list.
Regards,
Sriram.