[PATCH] Fix PR c/6660
DJ Delorie
dj@redhat.com
Mon May 27 19:54:00 GMT 2002
> DJ, is this disgusting "struct foo;" thing intended as compatibility
> with some other compiler, or is it accidental?
GCC didn't support unnamed members at all until it was added for
compatibility with MSVC (the platform SDK's headers use it
extensively, so many apps rely on it, so...). Such as this:
struct regs {
union {
struct { byte ah, al, bh, bl, ch, cl, dh, dl };
struct { word ax, bx, cx, dx };
};
word si, di, bp, sp;
} r;
and you'd see code like "r.al = r.bh + foo[r.dx] >> r.si" in an
application.
The first "bug" was that it went too far, and allowed unnamed
*anything* in structures, such as this:
struct foo {
int;
enum {a, b, c};
char *;
};
Since there are (or at least seem to be) legitimate reasons to scope
an unnamed enum there (to define the enumerations, but without
creating a field), we needed to cut back on the allowed types.
That's the history of this feature as far as I recall.
More information about the Gcc-patches
mailing list