Which C99 features are available in the MS Visual Studio compiler?

后端 未结 2 1467
自闭症患者
自闭症患者 2020-11-28 13:37

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

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 13:45

    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 partial 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).
    • C11 _Generic and type-generic math functions from tgmath.h.
    • _Complex type (optional in C11).
    • C11 multithreading.
    • C11 atomic primitives and types.

提交回复
热议问题