函数内部匿名static union为什么会在连接的时候报错
比如下面的代码,会报错,在Dev-C++下报
[Linker error] undefined reference to `startUp()::c'
在vxworks下的实际项目中报 holds reference to undefined symbol错误
但是如果把这个union放函数的外面,就不会报错。在函数内部,如果不是匿名的,无论是静态或者非静态,都不会报错。从理论上我不能解释,是否有对这个比较清楚的高手,解释下,谢谢
#include <iostream>
using namespace std;
void startUp()
{
static union
{
int c;
int d;
};
c=12;
cout<<d<<endl;
}
int main()
{
startUp();
getchar();
return 0;
}