Hello,
I am working on a library in C++, and the library goes with a header file
with a trailing comma at the end of some enumeration. Like this:
enum Abc {
ENUM_ONE,
ENUM_TWO
ENUM_THREE,
#ifdef HAVE_SOMETHING
ENUM_FOUR,
#endif
ENUM_FIVE,
};
I believe this isn't very good to give away such a thing, because for
example
gcc with "-pedantic" flag barks at it with "error: comma at the end of
enumeration".
The library isn't mine, and the header file is generated, so this isn't
particularly
easy for me to make an edit.
I'm still not very sure if this is a bad style or not?
The C++ Standard (7.2) forbids such declaration:
enum-specifier:
enum identifier { enumerator-list }
enumerator-list:
enumerator-definition
enumerator-list , enumerator-definition
while C99 (6.7.2.2) clearly allows:
enum-specifier:
enum identifier { enumerator-list }
enum identifier { enumerator-list , }
enumerator-list:
enumerator
enumerator-list , enumerator
The question is: are those hanging commas ok or not?
Thanks!
Jan