From owner-freebsd-hackers Thu Aug 6 09:23:19 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA01816 for freebsd-hackers-outgoing; Thu, 6 Aug 1998 09:23:19 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from austin.polstra.com (austin.polstra.com [206.213.73.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA01798 for ; Thu, 6 Aug 1998 09:23:05 -0700 (PDT) (envelope-from jdp@austin.polstra.com) Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.8.8/8.8.8) with ESMTP id JAA26353; Thu, 6 Aug 1998 09:22:37 -0700 (PDT) (envelope-from jdp) Message-Id: <199808061622.JAA26353@austin.polstra.com> To: Nicolas.Souchu@prism.uvsq.fr Subject: Re: C and static initialization with unions In-Reply-To: <19980806113159.49110@breizh.prism.uvsq.fr> References: <199808050103.SAA27705@usr02.primenet.com> <199808050149.SAA01073@dingo.cdrom.com> <19980806113159.49110@breizh.prism.uvsq.fr> Organization: Polstra & Co., Seattle, WA Cc: hackers@FreeBSD.ORG Date: Thu, 06 Aug 1998 09:22:37 -0700 From: John Polstra Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article <19980806113159.49110@breizh.prism.uvsq.fr>, Nicolas Souchu wrote: > Archie said: > > >>> > One non-portable nicety of gcc is that you can do this: > > union foo { > int iarg; > char carg; > }; > > static union foo x = { carg: 12 }; > > -Archie > <<< > > Is it allowed in FreeBSD? You can do anything you want in the privacy of your own home. But I would strongly oppose the use of this extension in any code being committed into FreeBSD itself. I suspect Bruce would make some noise about it too. Surely you can find a portable way to accomplish what you want to do, even if it means executing a few lines of code at run time. > Is all FreeBSD C source code portable? GCC extensions are occasionally used in FreeBSD. However, they are virtually always optional and for the purpose of (a) better efficiency, or (b) better compiler warnings. When GCC extensions are used, they are protected by "#ifdef __GNUC__", and an alternative portable implementation is provided in the "#else" clause. For case (a) the alternative implementation is less efficient; for case (b), it's a no-op. See for some examples of (b). -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-knowledge is always bad news." -- John Barth To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message