schot's answer是一个很好的。他声称
- Tags (names of structures, unions and enumerations).
我认为结构、 union 和枚举的标签具有不同的命名空间,因此这段代码完全没问题:
// In the same scope
struct T {};
union T {};
enum T {};
但从上面的引文推断,似乎所有标签都共享同一个命名空间。答案不够清楚还是我错了?
最佳答案
没有。
所有标签共享同一个命名空间。所以你不能有:
struct T {...};
union T {...};
enum T {...};
C11 draft N1570, 6.2.3 Name spaces of identifiers明确添加脚注。
32) There is only one name space for tags even though three are possible.
关于c - 结构标签、 union 标签和枚举标签是否有单独的命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47348273/