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

 

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 出现,其行为未定义。

上一篇:Shodan简单使用(一款黑暗版的谷歌)


下一篇:Javascript框架库漏洞验证