【发布时间】:2020-03-25 15:02:50
【问题描述】:
当我在全局范围内重新声明变量 x 时,此代码可以正常工作:
#include <stdio.h>
#include <stdlib.h>
int x = 12;
int x;
int main() {
printf("%d", x);
return 0;
}
然而,这段代码给了我一个错误:“redeclaration of 'x' with no links”
#include <stdio.h>
#include <stdlib.h>
int main() {
int x = 12;
int x;
printf("%d", x);
return 0;
}
我了解到,不允许多次重新定义,但允许重新声明。这仅适用于全局变量吗?
【问题讨论】: