Previous Table of Contents "New C Standard" commentary
390 An identifier can denote an object;
391 a function;
392 a tag or a member of a structure, union, or enumeration;
393 a typedef name;
394 a label name;
395 a macro name;
396 or a macro parameter.
397 The same identifier can denote different entities at different points in the program.
398 A member of an enumeration is called an enumeration constant.
399 Macro names and macro parameters are not considered further here, because prior to the semantic phase of program translation any occurrences of macro names in the source file are replaced by the preprocessing token sequences that constitute their macro definitions.
400 For each different entity that an identifier designates, the identifier is visible (i.e., can be used) only within a region of program text called its scope.
401 Different entities designated by the same identifier either have different scopes, or are in different name spaces.
402 There are four kinds of scopes: function, file, block, and function prototype.
403 (A function prototype is a declaration of a function that declares the types of its parameters.)
404 A label name is the only kind of identifier that has function scope.
It can be used (in a
406 Every other identifier has scope determined by the placement of its declaration (in a declarator or type specifier).
407 If the declarator or type specifier that declares the identifier appears outside of any block or list of parameters, the identifier has file scope, which terminates at the end of the translation unit.
408 If the declarator or type specifier that declares the identifier appears inside a block or within the list of parameter declarations in a function definition, the identifier has block scope, which terminates at the end of the associated block.
409 If the declarator or type specifier that declares the identifier appears within the list of parameter declarations in a function prototype (not part of a function definition), the identifier has function prototype scope, which terminates at the end of the function declarator.
410 If an identifier designates two different entities in the same name space, the scopes might overlap.
411 If so, the scope of one entity (the inner scope) will be a strict subset of the scope of the other entity (the outer scope).
412 Within the inner scope, the identifier designates the entity declared in the inner scope;
413 the entity declared in the outer scope is hidden (and not visible) within the inner scope.
414 Unless explicitly stated otherwise, where this International Standard uses the term identifier to refer to some entity (as opposed to the syntactic construct), it refers to the entity in the relevant name space whose declaration is visible at the point the identifier occurs.
415 Two identifiers have the same scope if and only if their scopes terminate at the same point.
416 Structure, union, and enumeration tags have scope that begins just after the appearance of the tag in a type specifier that declares the tag.
417 Each enumeration constant has scope that begins just after the appearance of its defining enumerator in an enumerator list.
418 Any other identifier has scope that begins just after the completion of its declarator.
419 Forward references: declarations (6.7), function calls (18.104.22.168), function definitions (6.9.1), identifiers (6.4.2), name spaces of identifiers (6.2.3), macro replacement (6.10.3), source file inclusion (6.10.2), statements (6.8).
Created at: 2008-01-30 02:39:40
The text from WG14/N1256 is copyright © ISO
Created at: 2008-01-30 02:39:40 The text from WG14/N1256 is copyright © ISO