C ++ 0x draft
9.5.6 Anonymous unions declared in a named namespace or in the global namespace must be declared static.
Why?
Update -
Based on Bart van Ingen Schenau and lothar respones, the best explanation so far may be the following:
If the same global anonymous union occurs in two translation units (for example, through a header file), then how can the rule of one definition be implemented? Are these two definitions the same and combined? Or are two definitions considered different? If they are regarded as the same thing, then the compiler, apparently, does the βmagicβ, otherwise it is not done for other objects. If they are regarded as the same thing, then the compiler does this without the explicit consent of the programmer ... therefore, I assume that explicit consent forcibly requires that it be declared as static.
c ++ c ++ 11 anonymous-types unions
Vatsan
source share