error C2143 missing ';' before type

int test(void)
{
if(1) { return -1;}
int k=0;
return k;
}

Under VisualStudioExpress 2008, I can compile above file if named test.cpp
If the file is named test.c then I get the error C2143 because the declaration comes out of order.
Though I selected the compiler option /TP (compile code as C++)...

I need to compile lapacke (C interface to lapack) and would like to avoid renaming of the .c to .cpp.
Is there any known workaround ?
for VC++, there's compiler switch /TP = compile as C++ (and /TC is compile as C)

You can get it from the IDE by selecting the file in the solution explorer and then changing its "C/C++" -> "Advanced" -> "Compile As" property.

Andy
Thanks, it worked.
I had set this option globally for the project, but this did not work.
One must set the option for each file indeed.
Topic archived. No new replies allowed.