我认为短语 "not previously declared to have external linkage" 是多余的,在 N4140 的 §3.5/3 项目符号点 (3.2) 中
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(我强调):
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.
我认为 (3.2) 中粗体字的短语是多余的,除非有人可以给出一个显式声明 const
但未声明 [=12=] 的变量的示例,并且之前声明为 external linkage
,因此结果变量具有 external linkage
.
这很简单:
extern const int i; // typically in header file
const int i = 0; // typically in source file
你问题中的句子确保这里没有冲突。第二个声明没有指定不同的不兼容链接,它只是继承了前一个声明的链接,这是你问题中的词实现的。
§3.5[basic.link]/3(我强调):
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.
我认为 (3.2) 中粗体字的短语是多余的,除非有人可以给出一个显式声明 const
但未声明 [=12=] 的变量的示例,并且之前声明为 external linkage
,因此结果变量具有 external linkage
.
这很简单:
extern const int i; // typically in header file
const int i = 0; // typically in source file
你问题中的句子确保这里没有冲突。第二个声明没有指定不同的不兼容链接,它只是继承了前一个声明的链接,这是你问题中的词实现的。