Why are global anonymous unions required to be declared as static?
My guess is that if it were allowed to define the union in a non static way it may violate the ODR (one definition rule)
Suppose anonymous unions were not required to be declared static, and the compiler encounters these two translation-units (after preprocessing):
File1:
union {
int a;
char b;
};
// Further contents referring to a and b
File2:
union {
int a;
char b;
};
// Further (different) contents referring to a and b
Are those two unions one an the same object, or are they supposed to be different objects?
I think that, in order to avoid unanswerable questions like this, it has been decided that namespace-scope anonymous unions have to be declared static.