How can I tell Visual Studio/Microsoft's C compiler to allow variable declarations after the first statement?

前端 未结 3 1235
感动是毒
感动是毒 2021-01-17 09:09

I have code that compiles on the GNUARM compiler, but Visual Studio 2010 issues errors. The issue involves declaring variables after the first statement in a C language file

3条回答
  •  粉色の甜心
    2021-01-17 09:40

    I made the same test with the default Visual Studio 2010 project, with the C file and /TP switch, and got the precompiled headers error. It can be removed by renaming stdafx.cpp to stdafx.c, or disabling precompiled headers for the whole project or for specific C files.

    I didn't find any other problems. However, this effectively converts C language to C++, which is not your intention, I think. C allows, however, to define a variable in the beginning of every {} block.

提交回复
热议问题