ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

C语言标准-标识符的链接-linkages of identifiers

2022-01-07 22:36:22  阅读:221  来源: 互联网

标签:identifiers C语言 linkages internal external declaration identifier 标识符 linkage


 

linkages of identifiers

标识符的链接 

 

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. 29) There are three kinds of linkage: external, internal, and none

 

不同作用域下声明的标识符 或者在同一作用域下面声明多次的标识符,在一个处理过程中可以指示同一个对象或者函数,这个处理过程叫做 linkage。 注: 不同的标识符之间不存在linkage。

有三种类型的 linkage

external

internal

none

 

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

组成程序的所有翻译单元和库中,拥有 external linkage的标识符 指示 同一个对象或函数。

在一个 翻译单元 内部,拥有 internal linkage 的标识符 指示 同一个对象或函数。

拥有 none linkage 的标识符,每个都指示一个独立的实体。

 

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.

具有 文件作用域的标识符,包含 static 修饰符,这个标识符 具有 internal linkage

 

For an identifier 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 修饰,如果前面一次是 internal或 external linkage, 后面一次的linkage 类型和前面的相同。

如果之前没出现过,或者前面出现时是 none linkage 类型,则后面一次是 external linkage 类型。

 

 

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.

函数没指定 storage-class 时,它等同于 使用 extern 修改的函数。具有 文件作用域的对象的标识符 没指定 storage-class ,则它是 external linkage 类型

 

The following identifiers have no linkage: 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

 

下列标识符 属于 none linkage 类型:

1、 既不是函数,也不是对象的标识符。

2、 函数参数标识符

3、 块作用域的对象标识符,没有使用extern 修饰。

 

 

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

在一个翻译单元内,同一个标识符 即以 internal linkage 出现又以 external linkage 出现,其行为未定义。

标签:identifiers,C语言,linkages,internal,external,declaration,identifier,标识符,linkage
来源: https://www.cnblogs.com/zhangzhiwei122/p/15777032.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有