我的项目中只有一个名为test.c的文件;如果我没有定义“TRUE”,下面的代码不能编译。我用vc。我只是想了解这种行为。请在这方面提出一些看法。了解静态变量的声明/初始化C
#ifdef TRUE
static int a;
static int a = 1;
#else
static int a = 1;
static int a;
#endif
int main (void)
{
printf("%d\n", a);
return 0;
}
-----------------------
#ifdef TRUE // both ok
int a;
int a = 1;
#else // both ok
int a = 1;
int a;
#endif
int main (void)
{
printf("%d\n", a);
return 0;
}
尝试包括错误消息。我们不是千里眼。 –
实际上将确切的错误信息粘贴到您的问题中通常是您应该做的。 –
'a'重新定义;不同的存储类别 – caisp