Global and static variables can only be initialized with constant expressions known at compile time. A call to foo() does not mean using a constant expression. In addition, the order in which global and static variables are initialized is not specified. Typically, calling foo() means that there must be a certain order, because the function can reasonably expect some other variables to be initialized.
IOW, in C, none of your codes are executed before main() .
In C ++, there are ways around it, but not in C.
Alexey Frunze
source share