Program linkage
Linkage determines whether identifiers that have
identical names refer to the same object, function, or other entity,
even if those identifiers appear in different translation units. The
linkage of an identifier depends on how it was declared. There are
three types of linkages:
- Internal linkage : identifiers can only be seen within a translation unit.
- External linkage : identifiers can be seen (and referred to) in other translation units.
- No linkage: identifiers can only be seen in the scope in which they are defined.
Linkage does not affect scoping, and normal name lookup considerations apply.
You can also have linkage between C++ and non-C++ code fragments, which is called language linkage. Language linkage enables the close relationship between C++ and C by allowing C++ code to link with that written in C. All identifiers have a language linkage, which by default is C++. Language linkage must be consistent across translation units, and non-C++ language linkage implies that the identifier has external linkage.