An anonymous union declared in a named namespace or in the global namespace has to be explicitly declared static:
static union { int num; char *pc; }; //anonymous union in global namespace namespace NS { static union { double d; bool b;}; //anonymous union in a named namespace } int main() { NS::d = 0.0; num = 5; pc = "str"; }