Reputation: 37894
The C standard says:
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.
What are "tag name spaces"?
Is the following a tagged name space?
struct T{};
Is it just the type name of a struct?
Does this terminology carry over into C++?
Upvotes: 2
Views: 1302
Reputation: 238401
Does this terminology carry over into C++?
No. "Tag names" are not mentioned in the C++ standard except for in the informative annex C++ and ISO C
where tag names are discussed in the context of C.
Upvotes: 2
Reputation: 5678
From 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).
So, T
is the name of a struct and in the same namespace as other “tags”, but not in the same namespace as, say, labels. I.e., you could have a label named T
in the same scope.
Upvotes: 7