This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc question about the embedded type definitions


Hi,

I have a question on embedded type definitions.

If in a structure definition, another type is defined. e.g.

typedef struct S1 {
struct S2 {
int a;
}
} S1;

is the data type S2 visible outside S1? Originally i think it is not visible outside.

But in gcc, I can declare a varible of type struct S2, and operate on it. e.g.:

S2 b;
b.a = 100;
printf("result = %d\n", b.a);

That implies the name of the structure type S2 must be unique in the C file. Am I right? Can anyone elaborate on this? Thanks!

Best Regards,
Zhang Wei


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]