Internal linkage
The following kinds of identifiers have internal linkage:
- Objects, references, or functions explicitly declared
static
- Objects or references declared in namespace scope (or global scope in C) with the specifier
const
orconstexpr
and neither explicitly declaredextern
, nor previously declared to have external linkage - Data members of an anonymous union
Function templates explicitly declared
static
Identifiers declared in the unnamed namespace
A function declared inside a block will usually have external linkage.
An object declared inside a block will usually have external linkage
if it is specified extern
. If a variable that has static
storage
is defined outside a function, the variable has internal linkage and
is available from the point where it is defined to the end of the
current translation unit.
If the declaration of an identifier has the keyword extern
and
if a previous declaration of the identifier is visible at namespace
or global scope, the identifier has the same linkage as the first
declaration.