This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Does traditional C allow initializing a union?


 > 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]