lkml.org 
[lkml]   [2000]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: creating a character driver
Richard B. Johnson wrote:
> Trailing commas are allowed, but not good coding style.

Some people seem to think they express the extensibility of the struct
better, particularly when combined with explicitly named fields in the
initializer. Also a patch like this

foo: 1,
+ bar: 2,

looks a little bit tidier than

- foo: 1
+ foo: 1,
+ bar: 2

But I guess this is just yet another case of individual taste.

> The hack to
> get around this, until the size stabilizes, is the trailing comma.

Note that both ANSI C (as of K&R 2nd ed., A.8.7 Initialization) and
egcs (tried 1.1.2) seem to agree that the trailing comma is never
required, even if you don't provide all fields.

Nathan, concerning field names in initializers: there seems to be
broad consensus (even on linux-kernel, believe it or not ;-) that
they are a good thing, so instead of

...
NULL, /* foo */
NULL, /* bar */
sth_useful, /* useful */
NULL, /* blah */
...

you could just write

...
useful: sth_useful,
...

(There's a little bit of disagreement whether this gcc-specific
syntax is preferable to the "new" ANSI-blessed syntax, but the
compromise reached so far is that the gcc syntax looks nice, and
one can always write a script to convert to ANSI, if necessary.)

- Werner

--
_________________________________________________________________________
/ Werner Almesberger, ICA, EPFL, CH werner.almesberger@ica.epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.048 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site