Reputation: 868
§3.5[basic.link]/3 (my emphasis):
A name having namespace scope (3.3.6) has internal linkage if it is the name of
(3.1) — a variable, function or function template that is explicitly declared static; or,
(3.2) — a non-volatile variable that is explicitly declared const or constexpr and neither explicitly declared extern nor previously declared to have external linkage; or
(3.3) — a data member of an anonymous union.
I believe the phrase in (3.2) in bold characters to be superfluous, unless someone could give an example of a variable that is explicitly declared const
, but not declared extern
, and which was previously declared to have external linkage
, and such that the resultant variable has external linkage
.
Upvotes: 0
Views: 146
Reputation:
That's easy:
extern const int i; // typically in header file
const int i = 0; // typically in source file
The sentence in your question makes sure there is no conflict here. The second declaration doesn't specify different incompatible linkage, it simply inherits the linkage from the previous declaration, and it's the words in your question that achieve that.
Upvotes: 5