This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
how to initialize union?
- From: "PRC" <panruochen at gmail dot com>
- To: "gcc-help" <gcc-help at gcc dot gnu dot org>
- Date: Sat, 22 Mar 2008 21:10:29 +0800
- Subject: how to initialize union?
union my_union {
struct {
int a;
int b;
};
struct {
char a;
short b;
void *c;
} v;
};
And I want to initialize 2 global variables, of `my_union' type, A and B to:
------------------------------------
A.a=1; A.b=2;
B.v.a='a'; B.v.b=16; B.v.c=NULL;
------------------------------------
I know how to initialize A by:
union my_union A = { 1, 2 };
But I don't know how to write the initializers for B.
Can gcc support this feature?