Search code examples
cnamespacesname-lookup

Do struct tags, union tags and enum tags have separate namespaces?


schot's answer is a good one. He claimed that

  • Tags (names of structures, unions and enumerations).

I think that the tags for structures, unions and enumerations have different namespaces, so that this code is completely fine:

// In the same scope
struct T {};
union T {};
enum T {};

But inferring from the quotation above, it looks like all tags share the same namespace. Is the answer not clear enough or am I wrong?


Solution

  • No.

    All the tags share the same namespace. So you are not allowed to have:

    struct T {...};
    union T {...};
    enum T {...};
    

    C11 draft N1570, 6.2.3 Name spaces of identifiers explicitly add s footnote.

    32) There is only one name space for tags even though three are possible.