c/language/scope

Each that appears in a C program is visible (that is, may be used) only in some possibly discontiguous portion of the source code called its scope.

Within a scope, an identifier may designate more than one entity only if the entities are in different s.

C has four kinds of scopes:
 * block scope
 * file scope
 * function scope
 * function prototype scope

Nested scopes
If two different entities named by the same identifier are in scope at the same time, and they belong to the same, the scopes are nested (no other form of scope overlap is allowed), and the declaration that appears in the inner scope hides the declaration that appears in the outer scope:

Block scope
The scope of any identifier declared inside a, including function bodies, , or within the parameter list of a begins at the point of declaration and ends at the end of the block or statement in which it was declared.

Block-scope variables have and  by default. Note that storage duration for non-VLA local variables begins when the block is entered, but until the declaration is seen, the variable is not in scope and cannot be accessed.

File scope
The scope of any identifier declared outside of any block or parameter list begins at the point of declaration and ends at the end of the translation unit.

File-scope identifiers have and  by default.

Function scope
A declared inside a function is in scope everywhere in that function, in all nested blocks, before and after its own declaration. Note: a label is declared implicitly, by using an otherwise unused identifier before the colon character before any statement.

Function prototype scope
The scope of a name introduced in the parameter list of a that is not a definition ends at the end of the function.

Note that if there are multiple or nested declarators in the declaration, the scope ends at the end of the nearest enclosing function declarator:

Point of declaration
The scope of structure, union, and enumeration tags begins immediately after the appearance of the tag in a type specifier that declares the tag.

The scope of enumeration constant begins immediately after the appearance of its defining enumerator in an enumerator list.

The scope of any other identifier begins just after the end of its declarator and before the initializer, if any:

As a special case, the scope of a that is not a declaration of an identifier is considered to begin just after the place within the type name where the identifier would appear were it not omitted.