[Prev][Next][Index]
Re: gcc says "structure has no member"
shuv ani,
I forget this little example, compile as .cc (c++).
struct FOO { /* this struct is in reality */
int no; /* something much, very much, bigger */
union { /* It is a struct of struct and/or union */
struct {
unsigned char c1;
} u;
unsigned char c2 ;
int i;
};
union {
char c3;
int j;
};
};
main()
{
struct FOO foo;
printf("%d\n", foo.no = 1);
printf("%c\n", foo.u.c1 = 'a');
printf("%c\n", foo.c2 = 'b');
printf("%d\n", foo.i = 65);
printf("%c\n", foo.c3 = 'c');
printf("%d\n", foo.j = 67);
printf("c1=%c\n", foo.u.c1);
printf("c3=%c\n", foo.c3);
}
--
Meir Dukhan