In this code, i
has static storage duration, and external linkage.
Storage duration refers to the lifetime of the variable's storage. Static storage duration means that the variable exists for the entire lifetime of the program.
Linkage refers to the relationship between names and objects. External linkage means that all instances of a name with external linkage denote the same object. Your int i;
will match a declaration extern int i;
from another translation unit.
The keyword static
is used in different contexts as a storage duration specifier and as a linkage specifier, so it is not clear to ask whether a variable is static
. Instead, the variable's storage duration and linkage should be considered.