Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 01 May 2009 09:31:08 -0700
From:      Bakul Shah <bakul@bitblocks.com>
To:        "Matthew Fleming" <matthew.fleming@isilon.com>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: C++ incompatability, was C99: Suggestions for style(9) 
Message-ID:  <20090501163108.576465B3B@mail.bitblocks.com>
In-Reply-To: Your message of "Fri, 01 May 2009 08:57:34 PDT." <06D5F9F6F655AD4C92E28B662F7F853E02ACA843@seaxch09.desktop.isilon.com> 
References:  <49F4070C.2000108@gmx.de><20090428114754.GB89235@server.vk2pj.dyndns.org> <49FAE4EA.1010205@gmx.de> <06D5F9F6F655AD4C92E28B662F7F853E02ACA843@seaxch09.desktop.isilon.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 01 May 2009 08:57:34 PDT "Matthew Fleming" <matthew.fleming@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090501163108.576465B3B>