This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Does traditional C allow initializing a union?
- To: jfc at mit dot edu
- Subject: Re: Does traditional C allow initializing a union?
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Tue, 13 Oct 1998 17:20:26 -0400 (EDT)
- Cc: egcs at cygnus dot com
> From: John Carr <jfc@MIT.EDU>
>
> > I'm trying to get emit-rtl.c: global_rtl.fld[] initialized by
> > using {{0}} (double nesting since its an array) and it doesn't work in
> > the traditional C case, (just as with the above code.)
>
> I wrote that code and wanted to do the same thing. See the comment
> lower down:
>
> /* Assign register numbers to the globally defined register rtx.
> This must be done at runtime because the register number field
> is in a union and some compilers can't initialize unions. */
>
> (And, I realized later, too many values aren't compile time constants.)
>
> Unless we move to ANSI C, unions can't have non-default initialization.
Thanks for the background info. I guess in order to remove the
warning from gcc about fld not being initialized, I'll only initialize
that member when #ifdef __STDC__ (or maybe __GNUC__) is true.
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Icon CMT Corp.