加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 在具有外部链接的匿名命名空间中声明的实体示例

发布时间:2020-12-16 04:51:54 所属栏目:百科 来源:网络整理
导读:鉴于§3.5/ 4中的以下语句(强调我的)和§7.3.1.1/ 1中的注释[94],我想在一个具有外部链接的未命名命名空间中声明的实体的一个单独示例. §3.5/ 4 An unnamed namespace or a namespace declared directly or indirectly within an unnamed namespace has int
鉴于§3.5/ 4中的以下语句(强调我的)和§7.3.1.1/ 1中的注释[94],我想在一个具有外部链接的未命名命名空间中声明的实体的一个单独示例.

§3.5/ 4

An unnamed namespace or a namespace declared directly or indirectly
within an unnamed namespace has internal linkage
. All other namespaces
have external linkage. A name having namespace scope that has not been
given internal linkage above has the same linkage as the enclosing
namespace if it is the name of

  • a variable; or
  • a function; or
  • a named class (Clause 9),or an unnamed class defined in a typedef declaration in which the class has the typedef name for linkage
    purposes (7.1.3); or
  • a named enumeration (7.2),or an unnamed enumeration defined in a typedef declaration in which the enumeration has the typedef name for
    linkage purposes (7.1.3); or
  • an enumerator belonging to an enumeration with linkage; or
  • a template.

关于§7.3.1.1/ 1的注释[94]:

Although entities in an unnamed namespace might have external linkage,
they are effectively qualified by a name unique to their translation
unit and therefore can never be seen from any other translation unit.

解决方法

您正在查看标准中的缺陷.

在2010年11月(CWG issue 1113)的C 11标准化过程中,使未命名的命名空间成员具有内部链接的更改发生得相当晚.因此,标准中的许多地方需要改变,但事实并非如此.其中一个是你引用的脚注.

CWG issue 1603,目前处于“就绪”状态(阅读:该决议很可能在下次委员会会议上通过),将修复此问题以及与未命名的命名空间成员提供内部链接相关的许多其他问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读