c - 默认情况下函数是外部的吗?

标签 c function extern

是一个在其声明和定义中没有指定存储类的函数:

void func(void); // declaration

void func(void) { // implementation
    
}

在其声明和定义中是否等同于具有extern 存储类的函数? :

extern void func(void); // declaration

extern void func(void) { // implementation
    
}

最佳答案

来自C标准(6.2.2标识符的链接)

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.

关于c - 默认情况下函数是外部的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71194445/

相关文章:

c - 动态数组和预建数据

c - 替代#define 以获得 C 中的灵活性

c++ - C++ 中的这些 extern 声明有什么区别?

r - 制作一个可管道化的函数

javascript - 连接而不是求和 (JavaScript)

c++ - 在库中包含具有外部 C 链接的函数

c++ - 在存在不可预测的类型别名的情况下如何处理显式模板实例化?

c - 带 C 代码的 4 位 LCD

c++ - 是否有一个库来解析 FTP LIST 命令的输出?

c - 请向我描述以下代码如何读取传感器的输出