可能重复:
Redefinition allowed in C but not in C++?C中的这个双声明是什么意思?
#include<stdio.h>
int i;
int i;
int main()
{
// int i;
// int i;
printf("%d\n",i);
return 0;
}
~
上面的代码运行wihtout给予任何错误gcc -Wall -Werror demo.c -o demo
但是,当我取消对local
i
变量注释掉global
i
,它给了我错误。
In function ‘main’:
demo.c:7:6: error: redeclaration of ‘i’ with no linkage
demo.c:6:6: note: previous declaration of ‘i’ was here
这是什么在这里的本地全球概念?,任何人请解释。
它给您带来了什么错误? – Mansfield
为什么downvoted .. ?? – Omkant