简体   繁体   中英

I believe the phrase “not previously declared to have external linkage” is superfluous, in §3.5/3 bullet point (3.2) in N4140

§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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM