Re: Comma at end of enum lists

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mikael Pettersson
Date: Saturday, March 29, 2008 - 10:19 am

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, 10:00 am)
Re: Comma at end of enum lists, Mikael Pettersson, (Sat Mar 29, 10:19 am)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 10:20 am)
Re: Comma at end of enum lists, Jacek Luczak, (Sat Mar 29, 10:22 am)
Re: Comma at end of enum lists, Al Viro, (Sat Mar 29, 10:25 am)
Re: Comma at end of enum lists, Jacek Luczak, (Sat Mar 29, 10:26 am)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 10:28 am)
Re: Comma at end of enum lists, Jan Engelhardt, (Sat Mar 29, 10:42 am)
Re: Comma at end of enum lists, Al Viro, (Sat Mar 29, 10:52 am)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 10:54 am)
Re: Comma at end of enum lists, Al Viro, (Sat Mar 29, 10:56 am)
Re: Comma at end of enum lists, H. Peter Anvin, (Sat Mar 29, 10:57 am)
Re: Comma at end of enum lists, Andreas Schwab, (Sat Mar 29, 11:13 am)
Re: Comma at end of enum lists, Jan Engelhardt, (Sat Mar 29, 11:24 am)
Re: Comma at end of enum lists, Andreas Schwab, (Sat Mar 29, 11:47 am)