Storage Class

The storage-class specifier in a function definition gives the function either extern or static storage class.

Syntax

function-definition :
declaration-specifiers opt declarator declaration-list opt compound-statement

declaration-specifiers :
storage-class-specifier declaration-specifiers opt
type-specifier declaration-specifiers opt
type-qualifier declaration-specifiers opt

storage-class-specifier : /* For function definitions */
extern
static

If a function definition does not include a storage-class-specifier, the storage class defaults to extern. You can explicitly declare a function as extern, but it is not required.

If the declaration of a function contains the storage-class-specifier extern, the identifier has the same linkage as any visible declaration of the identifier with file scope. If there is no visible declaration with file scope, the identifier has external linkage. If an identifier has file scope and no storage-class-specifier, the identifier has external linkage. External linkage means that each instance of the identifier denotes the same object or function. See “Understanding Lifetime, Scope, Visibility, and Linkage” for more information about linkage and file scope.

A function with static storage class is visible only in the source file in which it is defined. All other functions, whether they are given extern storage class explicitly or implicitly, are visible throughout all the source files that make up the program. If static storage class is desired, it must be declared on the first occurrence of a declaration (if any) of the function, and on the definition of the function.

Microsoft Specific

When the Microsoft extensions are enabled, a function originally declared without a storage class (or with externstorage class) is given staticstorage class if the function definition is in the same source file and if the definition explicitly specifies staticstorage class.¨