Re: creating a character driver

From: almesber@lrc.di.epfl.ch
Date: Tue Mar 07 2000 - 18:44:12 EST


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/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:24 EST