Linkages of identifiers(链接属性)

Link ages of identifiers (链接属性)

参考:【1】C99标准 【2】C和指针 3.6节

 

1 An identifier declared in different scopes or in the same scope more than once can be made to refer to the same object or function by a process called linkage.There are three kinds of linkage: external, internal, and none.

2 In the set of translation units and libraries that constitutes an entire program, each declaration of a particular identifier with external linkage denotes the same object or function. Within one translation unit, each declaration of an identifier with internal linkage denotes the same object or function. Each declaration of an identifier with no linkage denotes a unique entity.

注:没有链接属性的标识符 (none) 总是被当作单独的个体,也就是说该标识符的多个声明被当作独立不同的实体

       属于 internal 链接属性的标识符在同一源文件内的所有声明中都指向同一个实体,但位于不同源文件的多个声明则分属不同的实体

       属于 external 链接属性的标识符不论声明多少次、位于几个源文件都表示同一个实体

3 If the declaration of a file scope identifier for an object or a function contains the storage-class specifier static,the identifier has internal linkage.

注:处于文件作用域中标识符的链接属性默认都是 external 类型,除非使用 static 将其变为 internal 类型

4 For anidentifier declared with the storage-class specifier extern in a scope in which a prior declaration of that identifier is visible,if the prior declaration specifies internal or external linkage, the linkage of the identifier at the later declaration is the same as the linkage specified at the prior declaration. If no prior declaration is visible, or if the prior declaration specifies no linkage, then the identifier has external linkage.

注:当 extern 关键字用于源文件中一个标识符的第 1 次声明时,它指定该标识符具有 external 链接属性,但是,如果它用于该标识符的第二次或以后的声明时,它并不会更改由第 1 次声明所指定的属性链接

5 If the declaration of an identifier for a function has no storage-class specifier,its linkage is determined exactly as if it were declared with the storage-class specifier extern.If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external.

6 The following identifiers have nolinkage: an identifier declared to be anything other than an object or a function; an identifier declared to be a function parameter; a block scope identifier for an object declared without the storage-class specifier extern.

7 If, within a translation unit, the same identifier appears with both internal and external linkage, the behavior is undefined.

链接属性实例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值