Union initialization

Henry Spencer henry at utzoo.uucp
Sun Feb 19 10:05:13 AEST 1989


In article <816 at atanasoff.cs.iastate.edu> hascall at atanasoff.cs.iastate.edu (John Hascall) writes:
>  Does 'ANSI' C allow for union initialization?  If not, why not?

Yes it does.  But you won't like it.  Initialization of a union is
initialization of the first member.  Nobody thinks this is wonderful,
but it does at least define (e.g.) the initial value of a static union,
and it has the virtue that it has been implemented and found workable.
Designing a more general facility is tricky -- you really have to name
the member you're initializing, it can't always be guessed from the type
of the value -- and there doesn't seem to be a desperate need for it,
since we've been living without it for a long time.  I believe there
were some union-initialization proposals to X3J11, none of which got
enough support to make it in.
-- 
The Earth is our mother;       |     Henry Spencer at U of Toronto Zoology
our nine months are up.        | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list