Initialization of external variables
You can initialize any object with the
extern
storage
class specifier at global scope in C or at namespace scope in C++.
The initializer for an extern
object must either:
- Appear as part of the definition and the initial value must be described by a constant expression; or
- Reduce to the address of a previously declared object with static storage duration. You may modify this object with pointer arithmetic. (In other words, you may modify the object by adding or subtracting an integral constant expression.)
If you do not explicitly initialize an extern
variable,
its initial value is zero of the appropriate type. Initialization
of an extern
object is completed by the time the
program starts running.
Related information