scope
Each symbol (variable or function) has a scope, which is the part of code within which it can be used.
- global scope
- can be used from anywhere in the program
- file scope
- can be used only within the file in which it is defined
- block scope
- can only be used in the block of code in which it is defined
Keyword static
applied to a symbol defined outside any function
in the current file gives the symbol file scope.
Keyword extern
means the definition of the symbol is to be
found outside this file (so compiler doesn't complain.)
Best practice: keep the scope of symbols as small as possible.
Note: scope is of a symbol independent of its type information. If you write code that uses a global function whose prototype has not been provided, the compiler may complain but build the program anyway.