Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Aug 1998 09:22:37 -0700
From:      John Polstra <jdp@polstra.com>
To:        Nicolas.Souchu@prism.uvsq.fr
Cc:        hackers@FreeBSD.ORG
Subject:   Re: C and static initialization with unions
Message-ID:  <199808061622.JAA26353@austin.polstra.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <19980806113159.49110@breizh.prism.uvsq.fr>,
Nicolas Souchu  <Nicolas.Souchu@prism.uvsq.fr> 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 <sys/cdefs.h> 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



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