[英]How to “simulate” C99 in Visual Studio for variables declaration
I'm using Visual Studio 2012 to develop simple Win32 C programs. 我正在使用Visual Studio 2012开发简单的Win32 C程序。 I know that the VS compiler only supports C89, but I'd like to know if there is a way to override this limitation.
我知道VS编译器只支持C89,但我想知道是否有办法覆盖这个限制。
In particular I'd like to declare variables anywhere in my code, instead of only at the beginning of scope blocks (as C89 requires). 特别是我想在我的代码中的任何地方声明变量,而不是仅在范围块的开头声明(如C89所要求的)。
Thanks in advance. 提前致谢。
The choices I see: 我看到的选择:
This seems like a dated thread, but having landed here first while I was searching for the same question I thought I should post an update: 这看起来像是一个过时的线程,但是当我在寻找相同的问题时首先登陆这里,我认为我应该发布更新:
As of VS13, the Visual C++ compiler supports C99 style variable declarations. 从VS13开始,Visual C ++编译器支持C99样式变量声明。 More details here:
更多细节在这里:
http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx
Build your app using the C++ compiler. 使用C ++编译器构建您的应用程序。 This is the easiest way.
这是最简单的方法。 You can still write C code just name the file *.cpp
您仍然可以编写C代码,只需命名文件* .cpp即可
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.