At most one function with a particular name can have C language linkage
. Two declarations for a function with C language linkage with the same
function name (ignoring the namespace names that qualify it) that appear
in different namespace scopes refer to the same function
. Two
declarations for a variable with C language linkage with the same name
(ignoring the namespace names that qualify it) that appear in different
namespace scopes refer to the same variable
. An entity with C language linkage shall not be declared with the same name
as a variable in global scope, unless both declarations denote the same entity;
no diagnostic is required if the declarations appear in different translation units
. A variable with C language linkage shall not be declared with the same name as a
function with C language linkage (ignoring the namespace names that qualify the
respective names); no diagnostic is required if the declarations appear in
different translation units
. [
Note 4:
Only
one definition for an entity with a given name
with C language linkage can appear in the
program (see
[basic.def.odr]);
this implies that such an entity
must not be defined in more
than one namespace scope
. —
end note]
[
Example 4:
int x;
namespace A {
extern "C" int f();
extern "C" int g() { return 1; }
extern "C" int h();
extern "C" int x();
}
namespace B {
extern "C" int f();
extern "C" int g() { return 1; }
}
int A::f() { return 98; }
extern "C" int h() { return 97; }
—
end example]