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?
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.
No, they do not have separate namespaces. There is only one namespace for tags. This means
struct TS{};
union TU{};
int TS, TU;
is valid while
struct T{};
union T{};
is not. Two declarations of T are in the same namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With