Standard for union initialization?

Norman Diamond ndiamond at watdaisy.UUCP
Tue Jan 15 03:02:11 AEST 1985


Kevin Martin proposes an initializer of the form:
> 	element = value
> e.g.
> union {
> 	<type1> foo;
> 	<type2> bar;
> 	<type3> mumble;
> }baz = mumble = <initializer>;
> Since <initializer> can be an expression in C already, you might find that
> your compiler's grammar already allows this, and it is only detected as
> an error after further analysis.
> 
> Of course, if the "element =" is absent, the first element could be
> initialized. Similarly for the implicit zeroing of un-initialized
> static storage.

What is the datatype of "mumble"?  Assigning mumble = <initializer> or
mumble = <anything> should cause an error, unless <anything> is an int
or near-relative of an int.  And then, how can mumble be used as the
initializer for baz?

-- Norman Diamond

UUCP:  {decvax|utzoo|ihnp4|allegra|clyde}!watmath!watdaisy!ndiamond
CSNET: ndiamond%watdaisy at waterloo.csnet
ARPA:  ndiamond%watdaisy%waterloo.csnet at csnet-relay.arpa

"Opinions are those of the keyboard, and do not reflect on me or higher-ups."



More information about the Comp.lang.c mailing list