Storage duration determines how long storage for an object exists. An object has either static storage duration or automatic storage duration depending on its declaration. Descriptions of each follow:
Static storage | Is allocated at initialization and
remains available until the program ends. Objects have
static storage duration if they:
|
Automatic storage | Is allocated and removed according to
the scope of the identifier. Objects have automatic
storage duration if they are:
For example, storage for an object declared at block scope is allocated when the identifier is declared and removed when the closing brace (}) is reached. |
Note: Objects can also have heap
storage duration. Heap objects are created at runtime and storage
is allocated for them by calling a function such as malloc().
Scope of Identifier
Visibility
Program Linkage Between
Identifiers
Name Spaces