> > [snip exciting discussion on style]
> > 
> > > There are several C99 features used already, e.g. designated
initializers:
> > >   bla bli = { .blub = "foo", .arr[0] = 42 };
> > > Do you suggest that this should not be used, because it is
inconsistent
> > > with all the other existing compound initialisations?
> > 
> > Regarding this great feature of C99, sadly, it's not C++ compatible.
So
> > while designated initializers in a C source file are great, in a
header
> > file they will give a compile error if included in e.g. a C++ kernel
> > module (which otherwise would work fine).
> 
> Why would you put initializers in a header file? If included
> in more than one file, the linker will complain that the
> initialized variable is multiply defined.  If creating header
> files that get included in in only one file *and* you want to
> use initializers, why not use the right language for include
> file code.

Macros, like MALLOC_DEFINE, DB_COMMAND, etc., define initialized
variables when used.  These can't be changed to use named initializers
without breaking C++.

Thanks,
matthew
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to