C语言 如何使用 Visual Studio 2010 开发 C?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5770858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to develop C with Visual Studio 2010?
提问by Jeff
Is there a way to develop pure ANSI C with Visual Studio 2010?
有没有办法用 Visual Studio 2010 开发纯 ANSI C?
回答by Cody Gray
Yes, it's possible. MSDN provides some information here: ANSI C Compliance.
是的,这是可能的。MSDN 在此处提供了一些信息:ANSI C 合规性。
Step one is setting the compiler to produce C code, rather than C++ code. Do that from your project's Properties. Expand the C/C++ header, and click on "Advanced". Set the "Compile As" property to "Compile as C Code" (this is the same as specifying the /TCswitchon the command line). Even easier is to just name your files with a *.cextension.
第一步是设置编译器生成 C 代码,而不是 C++ 代码。从您的项目的属性中执行此操作。展开 C/C++ 标题,然后单击“高级”。将“Compile As”属性设置为“Compile as C Code”(这与在命令行上指定/TC开关相同)。更简单的方法是使用*.c扩展名命名您的文件。
Step two is disabling Microsoft's extensions to the ANSI standards. These are governed by the /Zaand /Zecompiler switches. You can find these in your project's Properties, as well. /Zacauses the compiler to emit an error for language constructs that are not compliant with the ANSI standard. The /Zeswitch enables Microsoft-specific extensions; you want to make sure that this one is turned off.
第二步是禁用 Microsoft 对 ANSI 标准的扩展。这些由/Za和/Ze编译器开关控制。您也可以在项目的属性中找到这些。/Za导致编译器为不符合 ANSI 标准的语言构造发出错误。该/Ze开关启用 Microsoft 特定的扩展;你想确保这个是关闭的。
Although I don't believe that Microsoft fullysupports the C99 standard. See (and vote for!) this bug report on MS Connect, this blog entryfrom the VC++ team, and this pagefor a concrete example of where that lack of support becomes evident. It does, however, have full support for the C90 standard.
虽然我不相信微软完全支持 C99 标准。请参阅(并投票!)关于 MS Connect 的此错误报告、来自 VC++ 团队的此博客条目以及此页面,以了解缺乏支持的具体示例。但是,它完全支持 C90 标准。
回答by Teoman Soygul
Via changing the file extension to .c will get you started but here are also some changes to the project file. See here for details: http://support.microsoft.com/kb/829488/en-us
通过将文件扩展名更改为 .c 将使您开始,但这里也对项目文件进行了一些更改。有关详细信息,请参见此处:http: //support.microsoft.com/kb/829488/en-us
There is also a good podcast on that: http://channel9.msdn.com/Blogs/Sam/C-Language-Programming-with-Visual-Studio-2010-Ultimate-Pro-or-VC-Express
还有一个很好的播客:http: //channel9.msdn.com/Blogs/Sam/C-Language-Programming-with-Visual-Studio-2010-Ultimate-Pro-or-VC-Express

