C++ incompatability, was C99: Suggestions for style(9)

Bakul Shah bakul at bitblocks.com
Fri May 1 16:50:52 UTC 2009


On Fri, 01 May 2009 08:57:34 PDT "Matthew Fleming" <matthew.fleming at isilon.com>  wrote:
> [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.


More information about the freebsd-hackers mailing list