什么是标签名称空间?
What are tag name spaces?
C 标准说:
7.1.3 Reserved identifiers
All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
什么是"tag name spaces"?
以下是标记名称吗space?
struct T{};
它只是结构的类型名称吗?
这个术语是否适用于 C++?
来自cppreference:
C allows more than one declaration for the same identifier to be in scope simultaneously if these identifiers belong to different categories, called name spaces:
- Label name space: all identifiers declared as labels.
- Tag names: all identifiers declared as names of structs, unions and enumerated types. Note that all three kinds of tags share one name space.
- Member names: all identifiers declared as members of any one struct or union. Every struct and union introduces its own name space of this kind.
- All other identifiers, called ordinary identifiers to distinguish from (1-3) (function names, object names, typedef names, enumeration constants).
因此,T
是结构的名称,与其他“标签”位于同一命名空间,但与标签不在同一命名空间。即,您可以在同一范围内有一个名为 T
的标签。
Does this terminology carry over into C++?
没有。 "Tag names" 除了在信息性附件 C++ and ISO C
中在 C++ 标准中未提及,其中标签名称在 C 的上下文中进行了讨论。
C 标准说:
7.1.3 Reserved identifiers
All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
什么是"tag name spaces"?
以下是标记名称吗space?
struct T{};
它只是结构的类型名称吗?
这个术语是否适用于 C++?
来自cppreference:
C allows more than one declaration for the same identifier to be in scope simultaneously if these identifiers belong to different categories, called name spaces:
- Label name space: all identifiers declared as labels.
- Tag names: all identifiers declared as names of structs, unions and enumerated types. Note that all three kinds of tags share one name space.
- Member names: all identifiers declared as members of any one struct or union. Every struct and union introduces its own name space of this kind.
- All other identifiers, called ordinary identifiers to distinguish from (1-3) (function names, object names, typedef names, enumeration constants).
因此,T
是结构的名称,与其他“标签”位于同一命名空间,但与标签不在同一命名空间。即,您可以在同一范围内有一个名为 T
的标签。
Does this terminology carry over into C++?
没有。 "Tag names" 除了在信息性附件 C++ and ISO C
中在 C++ 标准中未提及,其中标签名称在 C 的上下文中进行了讨论。