Namespaces are the various syntactic contexts within which an identifier can be used. Within the same context and the same scope, an identifier must uniquely identify an entity. Note that the term namespace as used here applies to C as well as C++ and does not refer to the C++ namespace language feature. The compiler sets up namespaces to distinguish among identifiers referring to different kinds of entities. Identical identifiers in different namespaces do not interfere with each other, even if they are in the same scope.
The same identifier can declare different objects as long as each identifier is unique within its namespace. The syntactic context of an identifier within a program lets the compiler resolve its namespace without ambiguity.
You can redefine identifiers in the same namespace using enclosed program blocks.
int get_item()
{
struct student /* structure tag */
{
char student[20]; /* structure member */
int section;
int id;
} student; /* structure variable */
goto student;
student:; /* null statement label */
return 0;
}
The compiler interprets each occurrence of student by
its context in the program: when student appears after the
keyword struct, it is a structure tag; when it appears in
the block defining the student type, it is a structure member
variable; when it appears at the end of the structure definition, it declares
a structure variable; and when it appears after the goto statement,
it is a label.