Description |
 |
You can use only one storage-class specifier in a declaration.
The typedef
keyword is listed as a storage-class specifier because it is syntactically
similar to one.
The keyword extern
affects the linkage of a function or object name. If the name has
already been declared in a declaration with file scope, the linkage
will be the same as in that previous declaration. Otherwise, the
name will have external linkage.
The static
storage-class specifier may appear in declarations of functions
or data objects. If used in an external declaration (either a function
or a data object), static
indicates that the name cannot be referenced by other translation
units. Using the static
storage class in this way allows translation units to have collections
of local functions and data objects that are not exported to other
translation units at link time.
If the static
storage class is used in a declaration within a function, the value
of the variable is preserved between invocations of that function.
The auto
storage-class specifier is permitted only in the declarations of
objects within blocks. An automatic variable is one that exists
only while its enclosing block is being executed. Variables declared
with the auto
storage-class are all allocated when a function is entered. Auto
variables that have initializes are initialized when their defining
block is entered normally. This means that auto
variables with initializes are not initialized when their declaring
block is not entered through the top.
The register
storage class suggests that the compiler store the variable in a
register, if possible. You cannot apply the &
(address-of) operator to register variables.
If no storage class is specified and the declaration appears
in a block, the compiler defaults the storage duration for an object
to automatic. If the declaration of an identifier for a function
has no storage-class specifier, its linkage is determined exactly
as if it were declared with the extern
storage-class specifier.
If no storage class is specified and the declaration appears
outside of a function, the compiler treats it as an externally visible
object with static duration.