c/language/storage class specifiers


 * - automatic duration with no linkage.
 * - automatic duration with no linkage. Also hints to the compiler to place the variable in the processor's register.
 * - static duration with internal linkage at file scope and no linkage at block scope.
 * - static duration with either internal or more usually external linkage.
 * - - thread storage duration.

Storage duration
All variables in a program have one of the following storage durations that determines its lifetime:


 * automatic storage duration. The variable is allocated at the beginning of the enclosing code block and deallocated at the end. This is the default for all variables, except those declared, or.


 * static storage duration. The variable is allocated when the program begins and deallocated when the program ends. Only one instance of the variable can exist. Variables declared with or  have this storage duration.


 * thread storage duration . The variable is allocated when the thread begins and deallocated when the thread ends. Each thread has its own instance of the variable. Only variables declared have this storage duration.  can only be declared for variables declared with  or  and cannot be used in a function declaration.


 * allocated storage duration. The variable is allocated and deallocated per request by using dynamic memory allocation functions.

Linkage
Linkage refers to the ability of a variable or function to be referred to in other scopes. If a variable or function with the same identifier is declared in several scopes, but cannot be referred to from all of them, then several instances of the variable are generated. The following linkages are recognized:


 * no linkage. The variable can be referred to only from the scope it is in (block scope). All variables with automatic, thread and dynamic storage durations have this linkage, as well as variables declared at block scope.


 * internal linkage. The variable can be referred to from all scopes in the current translation unit. All variables which are declared at file scope have this linkage, including variables declared at file scope.


 * external linkage. The variable can be referred to from any other translation units in the entire program. All variables which are declared either or  with no explicit storage-class specifier, but not, have this linkage.

Keywords
,, , ,

Example
Scope, Visibility, Lifetime: A variable with automatic storage duration is allocated with a high memory address. A variable with static storage duration is allocated with a low memory address; uninitialized variables are separated from initialized variables in memory for a fast internal initialization to zero. A variable with allocated storage duration is allocated memory above variables with static storage duration.

c/language/storage class specifiers c/language/storage class specifiers c/language/storage class specifiers c/language/storage class specifiers c/language/storage class specifiers c/language/storage class specifiers c/language/storage class specifiers c/language/storage class specifiers