c++visual-studio-2008comments

Strange visual studio 2008 C++ compiler error


I have three lines of code:

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

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.

Visual studios 2008 Windows XP 32 bit


Solution

  • 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.