Storage Classes and Scope

Class Duration Description Scope
Automatic temporary Declared within a function with no keyword or keyword auto. Confined to the block in which it is declared.
External persistent Declared outside of any functions or within a function with keyword extern. Global after point at which it is declared.
Static persistent Declared with keyword static either within or outside a function. If declared within a function it is local to the function. If declared outside functions it is global within that module.
Register temporary Declared with keyword register. A register variable is local to the function in which it is declared. Declaring a variable register does not necessarily mean it will be stored in a CPU register.


Discussion:

The default storage class of any variable is auto. An auto variable can be extern but it cannot be static. So auto and static are two mutually exclusive states.

The keyword extern is usually used to signify that the variable exists as a global variable in another source module or file. When the keyword extern is used for a variable no storage is set aside for the variable. It is assumed that the variable itself is declared elsewhere. The default storage class for functions is extern.

A function or variable can be declared static. If declared static a variable will retain its value between calls to the function it is declared in. Any extern static variable (or function) is global only within the module or file it is in.