Static storage duration
Static storage duration
An object whose identifier is declared without the storage-class specifier _Thread_local
, and either with external or internal linkage or with the storage-class specifier static
, has static storage duration. Its lifetime is the entire execution of the program and its stored value is initialized only once, prior to program startup.
Notes
Since its stored value is initialized only once, an object with static storage duration can profile the invocations of a function.
The other use of the keyword static
is file scope.
Example
Profiling the invocations of function f().
#include <stdio.h> void f (void) { static int count = 0; /* static va