如何使用 Visual Studio 2010 开发 C? [英] How to develop C with Visual Studio 2010?
问题描述
有没有办法用 Visual Studio 2010 开发纯 ANSI C?
Is there a way to develop pure ANSI C with Visual Studio 2010?
推荐答案
是的,这是可能的.MSDN 在此处提供了一些信息:ANSI C 合规性.
Yes, it's possible. MSDN provides some information here: ANSI C Compliance.
第一步是将编译器设置为生成 C 代码,而不是 C++ 代码.从您的项目的属性中执行此操作.展开 C/C++ 标题,然后单击高级".将编译为"属性设置为编译为 C 代码"(这与指定 /TC
开关 在命令行上).更简单的方法是使用 *.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 /TC
switch on the command line). Even easier is to just name your files with a *.c
extension.
第二步是禁用 Microsoft 对 ANSI 标准的扩展.这些由 /Za
和 /管理Ze
编译器开关.您也可以在项目的属性中找到这些./Za
导致编译器针对不符合 ANSI 标准的语言构造发出错误./Ze
开关启用 Microsoft 特定的扩展;你想确保这个关闭.
Step two is disabling Microsoft's extensions to the ANSI standards. These are governed by the /Za
and /Ze
compiler switches. You can find these in your project's Properties, as well. /Za
causes the compiler to emit an error for language constructs that are not compliant with the ANSI standard. The /Ze
switch enables Microsoft-specific extensions; you want to make sure that this one is turned off.
虽然我不相信微软完全支持 C99 标准.查看(并投票!)有关 MS Connect 的此错误报告, 此博客条目 来自 VC++ 团队,以及 此页面 的具体示例缺乏支持变得很明显.但是,它完全支持 C90 标准.
Although I don't believe that Microsoft fully supports the C99 standard. See (and vote for!) this bug report on MS Connect, this blog entry from the VC++ team, and this page for a concrete example of where that lack of support becomes evident. It does, however, have full support for the C90 standard.
这篇关于如何使用 Visual Studio 2010 开发 C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!