Scope
The use of an identifier is limited to
an area of program text known as the identifier's scope.
The four kinds of scope are function, file, block, and function prototype.
-
The scope of every identifier (other than label names)
is determined by the placement of its declaration
(in a declarator or type specifier).
-
The scope of structure, union and enumeration tags
begins just after the appearance of the tag in a type specifier
that declares the tag.
Each enumeration constant has scope that begins just after the
appearance of its defining enumerator in an enumerator list.
Any other identifier has scope that begins just after
the completion of its declarator.
-
If the declarator or type specifier
appears outside a function or parameter list,
the identifier has file scope, which terminates
at the end of the file (and all included files).
-
If the declarator or type specifier
appears inside a block or within the list
of parameter declarations in a function definition,
the identifier has block scope, which ends at the
end of the block (at the ``}'' that closes that block).
-
If the declarator or type specifier
appears in the list of parameter declarations
in a function prototype declaration, the identifier has
function prototype scope, which ends at the
end of the function declarator
(at the ``)'' that ends the list).
-
Label names always have function scope.
A label name must be unique within a function.
Next topic:
Storage duration
Previous topic:
Enumerations
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003