[Prev][Next][Index]
gcc says "structure has no member"
Hi,
I have a problem compiling a program under Linux.
I know that what i do is not very standard, but under Dos
my compiler, (microsoft) did not complain and work fine.
Begin *************
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;
}
unsigned char c2 ;
int i;
}
};
main()
{
struct FOO foo;
foo.no = 1;
foo.c1 = 'a';
foo.c2 = 'b';
foo.i = 4;
}
End *************
gcc -o foo foo.c
=>
foo.c:9: two or more data types in declaration of `c2'
foo.c:9: long, short, signed or unsigned invalid for `c2'
foo.c:12: warning: unnamed struct/union that defines no instances
foo.c:12: warning: no semicolon at end of struct or union
foo.c: In function `main':
foo.c:19: structure has no member named `c1'
foo.c:20: structure has no member named `c2'
foo.c:21: structure has no member named `i'
I think that it might exist a gcc option that allow to _not_
give a name to a struct/union embeded in struct/union
but allow to directly access the embeded fields using it/their
name(s).
Any idea ?
TIA
--
Meir