a global variable may one to two different storage classes in C, to my best knowledge, and the declaration may be given with two different keywords, correspodingly
extern int foo; //default
static int bar;
Static variables are only visible within the module of declaration, and cannot be exported. In case of extern declaration, the variable is in the common namespace of all modules linked, unless shadowed by static variable.
Whereas static variables have to be defined in their module, an extern variable may be defined somewhere else. It has to be defined if ever used.
My compiler (GCC) accepts
static int bar = 5;
but casts a complain at
extern int foo = 4;
It seems to be expected that extern variables are never defined with the keyword 'extern'. This leads to the following question:
What kind of storage class does the Object 'foo' in the example above have in the module where it is defined?