Nested types, anonymous unions, and functions
shall not be declared within an anonymous union
. The names of the members of an anonymous union shall be distinct from
the names of any other entity in the scope in which the anonymous union
is declared
. For the purpose of name lookup, after the anonymous union
definition, the members of the anonymous union are considered to have
been defined in the scope in which the anonymous union is declared
. [
Example 1:
void f() {
union { int a; const char* p; };
a = 1;
p = "Jennifer";
}
Here
a and
p are used like ordinary (non-member)
variables, but since they are union members they have the same address
. —
end example]