Sle*_*ead 5 c static extern linkage
当我尝试:
#include <stdio.h>
static int c1 = 10;
int main(){
{
extern int c1; //c1 here still has internal linkage
printf("%d",c1);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
什么都不会出错.但是当我尝试修改它时有点像这样:
#include <stdio.h>
static int c1 = 10;
int main(){
int c1 = 20; //This is where I modified.
c1++;
{
extern int c1;
printf("%d",c1);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
突然间,出现了一个错误.它说"变量先前声明'静态'重新声明'extern'".为什么?
逐字错误消息:
prog.c: In function ‘main’:
prog.c:11:20: error: variable previously declared ‘static’ redeclared ‘extern’
extern int c1;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
109 次 |
| 最近记录: |