MS Visual Studio 编译器中提供了哪些 C99 功能? [英] Which C99 features are available in the MS Visual Studio compiler?

查看:28
本文介绍了MS Visual Studio 编译器中提供了哪些 C99 功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,微软的 Visual Studio 编译器不支持 C99,看起来他们有 没有计划 支持它.

但是,编译器确实包含一些精选的功能,例如可变参数宏和 long long - 请参阅 这个答案:

<块引用>

我们收到了很多关于某些 C99 功能的请求,我们已经尝试实现它们(或类似功能).几个示例是可变参数宏、long long__pragma__FUNCTION____restrict.如果您发现其他 C99 功能对您的工作有用,请告诉我们!我们从 C 用户那里听到的消息不多,所以大声说出来,让自己听到

-- Arjun Bijanki,微软在 ISO C 标准委员会的代表 http://blogs.msdn.com/b/vcblog/archive/2007/11/05/iso-c-standard-update.aspx

此外,较新版本的 Visual Studio 似乎附带C99 所需的一些标头.

关于特定功能有很多问题 - 但我想知道的是:在哪里可以找到当前 MSVC 编译器支持/提供的 C99 功能列表?p>

我正在寻找一个列表像这个 gcc 的列表.

解决方案

幸运的是,微软在这个问题上的立场发生了变化.MSVC++ 12.0 版(Visual Studio 2013 的一部分)已添加支持

  • _Bool 类型.
  • 复合文字.
  • 指定的初始化器.
  • 将声明与代码混合使用.
  • __func__ 预定义标识符.

您可以查看 _MSC_VER 用于大于或等于 1800 的值,以查看是否支持这些功能.

标准库支持已更新,主要是自 MSVC 14.0 (Visual Studio 2015) 起完成.此版本还添加了 inline 关键字.

restrict 关键字、符合要求的预处理器和 C11 支持 已在 Visual Studio 2019 版本 16.8 中提供,但这不包括 C11 中可选的一些强制性 C99 功能.

早期版本已经支持的东西(我认为至少从 MSVC 7.1/Visual Studio 2003 开始​​):

  • // 样式注释.
  • long long 类型.
  • 灵活的数组成员(Microsoft 称它们为未调整大小的数组").
  • 可变参数宏(至少部分).

仍然缺少的东西:

  • 可变长度数组(C11 中可选,未计划).
  • _Complex 类型(C11 中可选,未计划).
  • C11 多线程(可选功能,在路线图上).
  • C11 原子原语和类型(可选功能,在路线图上).

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.

However, the compiler does include some cherry picked features such as variadic macros and long long - see the quotes in this answer:

Where we’ve received many requests for certain C99 features, we’ve tried to implement them (or analogues). A couple examples are variadic macros, long long, __pragma, __FUNCTION__, and __restrict. If there are other C99 features that you’d find useful in your work, let us know! We don’t hear much from our C users, so speak up and make yourselves heard

-- 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

Additionally, newer versions of Visual Studio seem to ship with some of the headers required by 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?

I'm looking for a list like this one for gcc.

解决方案

Fortunately, Microsoft's stance on this issue has changed. MSVC++ version 12.0 (part of Visual Studio 2013) added support for

  • _Bool type.
  • Compound literals.
  • Designated initializers.
  • Mixing declarations with code.
  • __func__ predefined identifier.

You can check the _MSC_VER macro for values greater than or equal to 1800 to see whether these features are supported.

Standard library support has been updated and is mostly complete since MSVC 14.0 (Visual Studio 2015). This release also added the inline keyword.

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.

Things that earlier versions already supported (I think since at least MSVC 7.1 / Visual Studio 2003):

  • // style comments.
  • long long type.
  • Flexible array members (Microsoft called them "unsized arrays").
  • Variadic macros (at least partially).

Things that are still missing:

  • Variable length arrays (optional in C11, not planned).
  • _Complex type (optional in C11, not planned).
  • C11 multithreading (optional feature, on the roadmap).
  • C11 atomic primitives and types (optional feature, on the roadmap).

这篇关于MS Visual Studio 编译器中提供了哪些 C99 功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆