From owner-freebsd-hackers@FreeBSD.ORG Fri May 1 16:50:51 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C39A1065674 for ; Fri, 1 May 2009 16:50:51 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from mail.bitblocks.com (mail.bitblocks.com [64.142.15.60]) by mx1.freebsd.org (Postfix) with ESMTP id 7C3438FC29 for ; Fri, 1 May 2009 16:50:51 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (localhost.bitblocks.com [127.0.0.1]) by mail.bitblocks.com (Postfix) with ESMTP id 576465B3B; Fri, 1 May 2009 09:31:08 -0700 (PDT) To: "Matthew Fleming" 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> Comments: In-reply-to "Matthew Fleming" message dated "Fri, 01 May 2009 08:57:34 -0700." Date: Fri, 01 May 2009 09:31:08 -0700 From: Bakul Shah Message-Id: <20090501163108.576465B3B@mail.bitblocks.com> Cc: FreeBSD Hackers Subject: Re: C++ incompatability, was C99: Suggestions for style(9) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2009 16:50:52 -0000 On Fri, 01 May 2009 08:57:34 PDT "Matthew Fleming" 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.