External linkage

Begin C only In global scope, identifiers for the following kinds of entities declared without the static storage class specifier have external linkage:
  • An object
  • A function
If an identifier in C is declared with the extern keyword and if a previous declaration of an object or function with the same identifier is visible, the identifier has the same linkage as the first declaration. For example, a variable or function that is first declared with the keyword static and later declared with the keyword extern has internal linkage. However, a variable or function that has no linkage and was later declared with a linkage specifier will have the linkage that was expressly specified. End C only
Begin C++ only In namespace scope, the identifiers for the following kinds of entities have external linkage:
  • A reference or an object that does not have internal linkage
  • A function that does not have internal linkage
  • A named class or enumeration
  • An unnamed class or enumeration defined in a typedef declaration
  • An enumerator of an enumeration that has external linkage
  • A template, unless it is a function template with internal linkage
  • A namespace, unless it is declared in an unnamed namespace
If the identifier for a class has external linkage, then, in the implementation of that class, the identifiers for the following entities will also have external linkage:
  • A member function
  • A static data member
  • A class of class scope
  • An enumeration of class scope
End C++ only