奇怪的visual studio 2008 C ++编译器错误

奇怪的visual studio 2008 C ++编译器错误

问题描述:

我有三行代码:

 //int pi;
 activation->structSize = sizeof(rmsActivationT);
 int pi; //program wont compile with this here

每次我取消注释第二个int并注释第一个int pi我得到这个错误:语法错误:缺少';'前'类型'。当我取消注释这个第一个int并评论第二个int,我的编译器不再抱怨了。

every time I uncomment the second int pi and comment the first int pi I get this error: syntax error : missing ';' before 'type'. When i uncomment this first int pi and comment the second int pi, my compiler doesn't complain anymore. This error has been bothering me for almost a full day now any ideas would be great.

感谢

视觉效果studios 2008
Windows XP 32位

Visual studios 2008 Windows XP 32 bit

您可能是将代码编译为C而不是C ++? C(在C99之前,Visual Studio不支持)要求块中的所有定义在任何其他语句之前。

Are you, perhaps, compiling the code as C instead of C++? C (prior to C99, which Visual Studio doesn't support) required that all definitions in a block precede any other statements.