Unnamed Structure declaration
Rob.McConnell@Zarlink.Com
Rob.McConnell@Zarlink.Com
Tue Mar 2 11:31:00 GMT 2004
> This is an easy one though.
> > struct wibble {
> > int a;
> > };
> > struct wabble {
> > struct wibble; /**** Compiler throws a wobbly here! ****/
> > int b;
> > };
> This isn't valid ISO C. Some compilers support this as an extension to
> the ISO C standard, in partticular, the Microsoft compiler does.
Thought as much ; ^ )
> Gcc supported this by default for a while, but there were some issues
> with it, so nowadays gcc only supports this if you use the
> -fms-extensions option.
>From a curiosity point of view, what issues cropped up?
BTW, I noticed on earlier version of GCC (e.g. 2.96), there were quite a
few bugs surrounding anonymous struct/unions and also empty structs (e.g.
struct {}). In particular I found that a field of a structure immediately
after an empty struct definition was not initialised correctly (defaulted
to 0). This applies to anonymous and named structs.
e.g. struct wibble {
struct {}; /*** Empty struct definition ***/
int a; };
struct wibble wibble_s = {.a = 1};
Here, the value of field "a" should be initialised to 1, but in fact it is
0 if you print the value out or look at the actual hexdump using "objdump
-s ....".
Do you know when these bugs were fixed so that I can say to people "use GCC
versions later than x.y" for my work?
Many thanks for your speedy and accurate response!
Cheers,
Rob : )
More information about the Gcc-bugs
mailing list