making it easier to use unions
mcdaniel at uicsrd.CSRD.UIUC.EDU
mcdaniel at uicsrd.CSRD.UIUC.EDU
Mon Jul 7 11:14:00 AEST 1986
C++ permits "anonymous unions" like
struct {
union {
int x;
char * y;
};
int z;
} zap;
so
zap.z = zap.x;
is legal. I don't find it confusing. [I think that anonymous structs
should likewise be permitted in C++ -- which is outside the scope of C.]
In such a case, I would say
struct { /* or union if appropriate */
int x;
char * y;
};
int z;
outside another struct/float would likewise define 3 external
variables named x, y, and z.
Anonymous structs could thus be described as only for purposes of
grouping (like parentheses) but do not affect scope; all identifiers
declared therein are "exported" to the next scope out, whatever it may
be.
Anonymous unions would be for grouping and for storage overlay.
As for C: probably too late to add anonymity. Anonymous is a lousy
keyword: too hard to speel.
More information about the Comp.lang.c
mailing list