Categories and Scope of Identifiers
Each identifier belongs to exactly one of the following four categories:
Label names
The tags of structures, unions, and enumerations. These are identifiers that follow one of the keywords
struct,union, orenum(see Section 1.10).Names of structure or union members. Each structure or union type has a separate name space for its members.
All other identifiers, called ordinary identifiers.
Identifiers of different categories may be identical. For example, a label name may also be used as a function name. Such re-use occurs most often with structures: the same string can be used to identify a structure type, one of its members, and a variable; for example:
struct person {char *person; /*...*/} person;The same names can also be used for members of different structures.
Each identifier in the source code has a scope . The scope is that portion of the program in which the identifier can be used. The four possible scopes are:
- Function prototype
Identifiers in the list of parameter declarations of a function prototype (not a function definition) have function prototype scope . Because these identifiers have no meaning outside the prototype itself, they are little more than comments.
- Function
Only label names have function scope . Their use is limited to the function block in which the label is defined. Label names must also be unique within the function. The
gotostatement causes a jump to a labelled statement within the same function.- Block
Identifiers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access