块作用域和内部链接?
Block scope and internal linkage?
来自 C18 标准 (6.7.9):
If the declaration of an identifier has block scope, and the
identifier has external or internal linkage, the declaration shall
have no initializer for the identifier.
我对块作用域+外部链接没问题。但是,我看不出标识符如何具有块作用域和内部链接。这可能吗?
如果你的全局定义了
static int hui;
它有内部链接。那么
void f(void) {
extern int hui;
}
引用具有内部链接的同一个对象,即使关键字说 extern
.
所以 extern
用词不当,应该是 linkage
左右。
来自 C18 标准 (6.7.9):
If the declaration of an identifier has block scope, and the identifier has external or internal linkage, the declaration shall have no initializer for the identifier.
我对块作用域+外部链接没问题。但是,我看不出标识符如何具有块作用域和内部链接。这可能吗?
如果你的全局定义了
static int hui;
它有内部链接。那么
void f(void) {
extern int hui;
}
引用具有内部链接的同一个对象,即使关键字说 extern
.
所以 extern
用词不当,应该是 linkage
左右。