函数声明中显式 "extern" 关键字的 meaning/significance 是什么?
What is the meaning/significance of explicit "extern" keyword in function declaration?
请解释为什么在函数声明中使用extern
?
main.c
...
pthread_create(&displayThread, &attr, displayThrFxn, &displayEnv);
...
display.h
extern Void *displayThrFxn(Void *arg);
为什么 extern
?
display.c
...
Void *displayThrFxn(Void *arg)
{
// some code
}
...
这里使用extern
有点多余。默认情况下,如果没有指定,函数有外部链接。
引用 C11
标准,章节 §6.2.3
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
. [...]
请解释为什么在函数声明中使用extern
?
main.c
...
pthread_create(&displayThread, &attr, displayThrFxn, &displayEnv);
...
display.h
extern Void *displayThrFxn(Void *arg);
为什么 extern
?
display.c
...
Void *displayThrFxn(Void *arg)
{
// some code
}
...
这里使用extern
有点多余。默认情况下,如果没有指定,函数有外部链接。
引用 C11
标准,章节 §6.2.3
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
. [...]