Re: gnu extensions
Keith Thompson <kst-u@mib.org> writes:
[color=blue]
> Russell Shaw <rjshawN_o@s_pa m.netspace.net. au> writes:[color=green]
>> Richard Heathfield wrote:[color=darkred]
>>> jacob navia said:
>>>
>>>>Keith Thompson a icrit :
>>>>
>>>>>C99 allows a trailing comma on an enumerator list.
>>>>>
>>>>What was before an extension is now in the standard.
>>>>
>>>>Why?
>>> No idea. It's a completely pointless extension. The only reason I
>>> can think of for it is consistency with the equally pointless
>>> trailing comma on an initialiser list.[/color]
>>
>> The trailing commas are *very* useful for making algorithmically generated
>> C code easier.[/color]
>
> Really? I can see that the trailing comma makes it marginally easier
> to generate an enum type declaration, but keeping track of whether a
> comma is needed shouldn't be *that* difficult.[/color]
It is a hassle if you want to use the C preprocessor as your
generator. Consider:
enum {
#ifdef XYZZY
abc,
#endif
#ifdef FUBAR
def,
#endif
};
Now consider how to rewrite this to never end in a comma.
(Adding a sentinel element is the easiest way, but it seems
unclean if you don't otherwise have a use for one.)
--
"The way I see it, an intelligent person who disagrees with me is
probably the most important person I'll interact with on any given
day."
--Billy Chambless
Keith Thompson <kst-u@mib.org> writes:
[color=blue]
> Russell Shaw <rjshawN_o@s_pa m.netspace.net. au> writes:[color=green]
>> Richard Heathfield wrote:[color=darkred]
>>> jacob navia said:
>>>
>>>>Keith Thompson a icrit :
>>>>
>>>>>C99 allows a trailing comma on an enumerator list.
>>>>>
>>>>What was before an extension is now in the standard.
>>>>
>>>>Why?
>>> No idea. It's a completely pointless extension. The only reason I
>>> can think of for it is consistency with the equally pointless
>>> trailing comma on an initialiser list.[/color]
>>
>> The trailing commas are *very* useful for making algorithmically generated
>> C code easier.[/color]
>
> Really? I can see that the trailing comma makes it marginally easier
> to generate an enum type declaration, but keeping track of whether a
> comma is needed shouldn't be *that* difficult.[/color]
It is a hassle if you want to use the C preprocessor as your
generator. Consider:
enum {
#ifdef XYZZY
abc,
#endif
#ifdef FUBAR
def,
#endif
};
Now consider how to rewrite this to never end in a comma.
(Adding a sentinel element is the easiest way, but it seems
unclean if you don't otherwise have a use for one.)
--
"The way I see it, an intelligent person who disagrees with me is
probably the most important person I'll interact with on any given
day."
--Billy Chambless
Comment