Does traditional C allow initializing a union?

John Carr jfc@mit.edu
Tue Oct 13 04:54:00 GMT 1998


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




More information about the Gcc mailing list