高手:extern编译出错??

FengPrince FengPrince 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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.

int main()
{
int i;
extern int i;
return ;
}
编译出错,说i无连接,明显跟最后一句话相悖啊!

PS:我承认,这个问题a很无聊。。。
...全文

相关推荐

extern用法详解extern用法详解extern用法详解extern用法详解

extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解extern用法详解

sookey

C++中extern关键字使用

chapter1、如何混合编译C语言和C++   实际开发过程中,C++中会调用C与语言编写的代码,我在网络上面找到一篇写得很好的文章   http://blog.csdn.net/keensword/article/details/401114   方法一、全局函数和变量在devVar.c文件中实现,在extern.cpp文件中使用extern关键字声明在devVar.c文件中定义的函数和变量。   devVar.c文件的代码如下所示:   #include   int i = 1;   void func()   {   printf("%d",i++

weixin_38668160

浅析extern “C”的作用

关于extern “C”的作用和意思,网上资料已经有很多了(我也参考了几篇),不过我还是觉得有必要自己总结一下,毕竟“好记性不如烂笔头”嘛~~

weixin_38621638

extern用法详解

针对C及C++环境下,extern的不同使用的详细解析。对新手及高手都有较大参考价值。

yoqio

C/C++ 中extern关键字详解

C/C++ 中extern关键字详解 在C/C++编程过程中,经常会进行变量和函数的声明和定义,各个模块间共用同一个全局变量时,此时extern就派上用场了。 定义 extern可以置于变量或者函数前,以标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其定义,不需要分配内存,直接使用。 推荐:在.h中声明,因为在头文件定义的话,其他模块include此头文件,就会报重复定义错误 实验结论 1、在.h中声明 extern int g_a; 在.c中定义 int g_a=1; 在两个其他文件中引入.h g_a就是唯一的 2、在.h中声明 int g_a;

weixin_38632247
评论 14
收藏 已收藏
分享
返回顶部
FengPrince
C语言 70,039 成员 243,237 内容