Objects and variables declared as extern declare an object that is defined in another translation unit or in an enclosing scope as having external linkage.
Declaration of const variables with the extern storage class forces the variable to have external linkage. An initialization of an extern const variable is allowed in the defining translation unit. Initializations in translation units other than the defining translation unit produce undefined results.
The following code shows two extern declarations, DefinedElsewhere (which refers to a name defined in a different translation unit) and DefinedHere (which refers to a name defined in an enclosing scope):
extern int DefinedElsewhere; // Defined in another translation
// unit.
int main()
{
int DefinedHere;
{
extern int DefinedHere; // Refers to DefinedHere in
// the enclosing scope.
}
return 0;
}