views:

52

answers:

1

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.

Thanks

Visual studios 2008 Windows XP 32 bit

+5  A: 

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.

Jerry Coffin
You beat me to it. This is almost certainly the problem, as that is exactly the error that will result. If the file is a .cc/.cpp file, check the "C++/Advanced/Compile As" setting in the project properties. If your file is a ".C" file, remember that Windows is not case-sensitive, you will need to rename the source files or use the above setting to force C++ compilation.
Tim Sylvester