login
Header Space

 
 

Re: Comma at end of enum lists

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jacek Luczak <difrost.kernel@...>
Cc: <linux-kernel@...>
Date: Saturday, March 29, 2008 - 1:19 pm

Jacek Luczak writes:
 > Hi All,
 > 
 > I've found that in many enum lists, there's a comma at the end, e.g. 
 > (arch/x86/kernel/early_printk.c):
 > 
 > enum {
 >          MAGIC1 = 0xBACCD00A,
 >          MAGIC2 = 0xCA110000,
 >          XOPEN = 5,
 >          XWRITE = 4,
 > };
 > 
 > Just out of curiosity, is there any particular reason here (no word in 
 > CodingStyle about that).

Yes. This idiom allows you to add or remove items without
changing adjacent lines.

In a language with strict a comma-as-separator rule you can
get this benefit by placing the comma before new items rather
than after existing items:

enum {	FOO
	,FIE
	,FUM
};

but luckily C doesn't need this perversion.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Comma at end of enum lists, Jacek Luczak, (Sat Mar 29, 1:00 pm)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 1:20 pm)
Re: Comma at end of enum lists, Al Viro, (Sat Mar 29, 1:25 pm)
Re: Comma at end of enum lists, Jacek Luczak, (Sat Mar 29, 1:26 pm)
Re: Comma at end of enum lists, Al Viro, (Sat Mar 29, 1:56 pm)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 1:57 pm)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 1:28 pm)
Re: Comma at end of enum lists, Al Viro, (Sat Mar 29, 1:52 pm)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 1:54 pm)
Re: Comma at end of enum lists, Jan Engelhardt, (Sat Mar 29, 1:42 pm)
Re: Comma at end of enum lists, Mikael Pettersson, (Sat Mar 29, 1:19 pm)
Re: Comma at end of enum lists, Andreas Schwab, (Sat Mar 29, 2:13 pm)
Re: Comma at end of enum lists, Jan Engelhardt, (Sat Mar 29, 2:24 pm)
Re: Comma at end of enum lists, Andreas Schwab, (Sat Mar 29, 2:47 pm)
Re: Comma at end of enum lists, Jacek Luczak, (Sat Mar 29, 1:22 pm)
speck-geostationary