A file scope data declaration appears outside any function definition. It describes a variable and makes that variable accessible to all functions that are in the same file and whose definitions appear after the declaration.
A file scope data definition is a data declaration at file scope that also causes storage to be allocated for that variable. All objects whose identifiers are declared at file scope have static storage duration.
Use a file scope data declaration to declare variables that you want to have external linkage.
The only storage class specifiers you can put in a file scope data declaration are static, extern, and typedef. If you specify static, all variables defined in it have internal linkage. If you do not specify static, all variables defined in it have external linkage. If you specify the storage class you can omit the type specifier. If you omit the type specifier, all variables defined in that declaration receive the type int.
Initialization
You can initialize any object with
file scope. If you do not initialize a file scope variable, its
initial value is zero of the appropriate type. If you do
initialize it, the initializer must be described by a constant
expression, or it must reduce to the address of a previously
declared variable at file scope, possibly modified by a constant
expression. Initialization of all variables at file scope takes
place before the main function begins running.
Storage
All objects with file scope data
declarations have static storage duration. Storage is allocated
at runtime and freed when the program stops running.
Declarations Overview
Block Scope Data
Declarations
Declarators
Storage Class
Specifiers
Initializers
Type Specifiers