[comp.lang.c] Initializing unions

dave@dms3b1.UUCP (Dave Hanna) (12/14/89)

I hope this is not a stupid question, and, since I don't read this group,
I hope it is not inappropriate to post it here.

How (syntactically) do you declare an initial value for a union?
E.g., in the following code fragment, the structure "struct_examp"
is initialized successfully, but I can find no parallel construct
to initialize the union "union_examp":

    typedef struct {
	long val1;
	char *val2;
    } DEF;

    static DEF struct_examp = { 
    (long) 1, 
    (char *) 1 };

    typedef union {
	long val1;
	char *val2;
    } ABC;

    static ABC union_examp =  {
    (long) 1} ; 


(Actually, I am trying to initialize an array of structures,
in which one of the fields is a union.)

Please e-mail replies.  I will not see them if they are posted, as
I don't receive this group.

    Dave Hanna
-- 
Dave Hanna,  Infotouch Systems, Inc. |  "Do or do not -- There is no try"
P.O. Box 584, Bedford, TX 76095      |                        - Yoda
(214) 358-4534   (817) 540-1524      |
UUCP:  ...!texbell!letni!dms3b1!dave |