[英]Which C99 features are available in the MS Visual Studio compiler?
It's well known that Microsoft's Visual Studio compiler does not support C99, and it looks like they have no plans to support it .众所周知,微软的 Visual Studio 编译器不支持 C99,看起来他们也没有计划支持它。
However, the compiler does include some cherry picked features such as variadic macros and long long
- see the quotes in this answer :但是,编译器确实包含了一些精心挑选的功能,例如可变参数宏和
long long
- 请参阅此答案中的引号:
Where we've received many requests for certain C99 features, we've tried to implement them (or analogues).
在我们收到许多对某些 C99 特性的请求的地方,我们已经尝试实现它们(或类似物)。 A couple examples are variadic macros,
long long
,__pragma
,__FUNCTION__
, and__restrict
.几个例子是可变参数宏、
long long
、__pragma
、__FUNCTION__
和__restrict
。 If there are other C99 features that you'd find useful in your work, let us know!如果您发现其他 C99 功能对您的工作有用,请告诉我们! We don't hear much from our C users, so speak up and make yourselves heard
我们从 C 用户那里听到的消息不多,所以说出来,让自己被听到
-- Arjun Bijanki, Microsoft's representative on the ISO C standard committee http://blogs.msdn.com/b/vcblog/archive/2007/11/05/iso-c-standard-update.aspx
-- Arjun Bijanki,微软在 ISO C 标准委员会的代表http://blogs.msdn.com/b/vcblog/archive/2007/11/05/iso-c-standard-update.aspx
Additionally, newer versions of Visual Studio seem to ship with some of the headers required by C99 .此外,较新版本的 Visual Studio 似乎附带了 C99 所需的一些标头。
There are lots of questions about specific features - but what I wan't to know is: Where can I find a list of the C99 features supported/provided by the current MSVC compiler?关于特定功能有很多问题 - 但我想知道的是:在哪里可以找到当前 MSVC 编译器支持/提供的 C99 功能列表?
I'm looking for a list like this one for gcc .我正在为 gcc寻找这样的列表。
Fortunately, Microsoft's stance on this issue has changed.幸运的是,微软在这个问题上的立场已经改变。 MSVC++ version 12.0 (part of Visual Studio 2013) added support for
MSVC++ 12.0 版(Visual Studio 2013 的一部分) 添加了对
_Bool
type. _Bool
类型。__func__
predefined identifier. __func__
预定义标识符。 You can check the _MSC_VER
macro for values greater than or equal to 1800 to see whether these features are supported.您可以检查
_MSC_VER
宏中是否有大于或等于 1800 的值,以查看是否支持这些功能。
Standard library support has been updated and is mostly complete since MSVC 14.0 (Visual Studio 2015). 标准库支持已更新,自 MSVC 14.0 (Visual Studio 2015) 起已基本 完成。 This release also added the
inline
keyword.此版本还添加了
inline
关键字。
The restrict
keyword, a conformant preprocessor and C11 support arrived in Visual Studio 2019 Release 16.8, but this doesn't include some mandatory C99 features made optional in C11.在 Visual Studio 2019 版本 16.8 中提供了
restrict
关键字、符合标准的预处理器和C11 支持,但这不包括在 C11 中成为可选的一些强制性 C99 功能。
Things that earlier versions already supported (I think since at least MSVC 7.1 / Visual Studio 2003):早期版本已经支持的东西(我认为至少从 MSVC 7.1 / Visual Studio 2003 开始):
//
style comments. //
样式注释。long long
type. long long
型。 Things that are still missing:仍然缺少的东西:
_Complex
type (optional in C11, not planned). _Complex
类型(在 C11 中可选,未计划)。I believe that the only non-library language feature of C99 (that's not in C90) supported in MSVC is //
comments.我相信 MSVC 支持的 C99 的唯一非库语言功能(不在 C90 中)是
//
注释。 Other than that when compiling in C mode, the only C99 features you'll get are due to C99 library features that Microsoft has brought in because those features were brought in the C++ standard/draft standard/TR that the MS compiler was supporting.除了在 C 模式下编译时,您将获得的唯一 C99 功能是由于 Microsoft 引入的 C99 库功能,因为这些功能是在 MS 编译器支持的 C++ 标准/草案标准/TR 中引入的。 For example, you got
stdint.h
in VS 2010 because it was in the C++ TR1 draft.例如,您在 VS 2010 中得到
stdint.h
,因为它在 C++ TR1 草案中。
Microsoft has made it clear that they see no strong push from the market to allocate resources to support C99 in MSVC, so it's almost certain that the only parts of C99 you'll see in MSVC's C compiler mode are those that get brought in because of C++. Microsoft 已明确表示,他们认为市场不会大力推动在 MSVC 中分配资源以支持 C99,因此几乎可以肯定,您将在 MSVC 的 C 编译器模式中看到的 C99 的唯一部分是由于以下原因而引入的部分C++。
One of things that I find frustrating is that non-library C99 language features that have been part of C++ for a long time are not available in C mode.我感到沮丧的一件事是,长期以来一直是 C++ 一部分的非库 C99 语言功能在 C 模式下不可用。 Personally, I'd find it very helpful if just the C99 ability to mix statements with declarations were supported when compiling C code.
就我个人而言,如果在编译 C 代码时仅支持 C99 将语句与声明混合的能力,我会发现它非常有帮助。
But it seems that the language features you see in C with MSVC today is what you'll get from here on.但是,您今天在 MSVC 中在 C 中看到的语言功能似乎就是您从这里获得的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.