Name spaces are identifier classifications based on the context of the identifier's use in the program. Name spaces allow the same identifier to simultaneously stand for an object, statement label, structure tag, union member, and enumeration constant. Simultaneous use of an identifier in the same scope for two different entities without ambiguity is possible only if the identifiers are in different name spaces. The context of the identifier's use resolves the ambiguity over which of the identically named entities is desired.
There are four different name spaces:
For example, the identifier
flower can be used in one
block to stand for both a variable and an enumeration tag, because
variables and tags are in different name spaces. Subsequently, an
inner block can redefine the variable
disturbing the enumeration tag
flower . Therefore, when
using the same identifier for various purposes, analyze the name
space and scope rules governing the identifier. Section 2.3 presents the scope rules.
A structure, union, and enumeration member name can be common to each of these objects at the same time. The use of the structure, union, or enumeration name in the reference to the member resolves any ambiguity about which identifier is meant. However, the structure, union, or enumeration tag must be unique, since the tags of these three object types share the same name space.