Scope Rules

 

5.12  Scope Rules

      File scope

    Identifier defined outside function, known in all functions

    Used for global variables, function definitions, function prototypes

      Function scope 

    Can only be referenced inside a function body

    Used only for labels (start:, case: , etc.)

      Block scope 

    Identifier declared inside a block 

    Block scope begins at declaration, ends at right brace

    Used for variables, function parameters (local variables of function)

    Outer blocks "hidden" from inner blocks if there is a variable with the same name in the inner block

      Function prototype scope

    Used for identifiers in parameter list