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

Community
  • 1
  • 1
Timothy Jones
  • 21,495
  • 6
  • 60
  • 90
  • There are none. All the features you are referring to are C++ features. – Jesse Good Mar 07 '12 at 23:30
  • @Jesse: I've updated the question to make it clear that there are some C99 features intentionally supported in the Visual Studio compiler. – Timothy Jones Mar 07 '12 at 23:41
  • 8
    If you want to use C99, why not just use a compiler that supports it? – Carl Norum Mar 07 '12 at 23:41
  • 1
    @Timothy Jones: In the quote you added, it says `we’ve tried to implement them (or analogues).`, what this means is that they are **not** C99 features, but are exact replicas. There is a difference. – Jesse Good Mar 07 '12 at 23:47

2 Answers2

37

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.

Visual Studio 2022 version 17.5 added support for C11 atomic primitives and types (stdatomic.h).

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).
nwellnhof
  • 32,319
  • 7
  • 89
  • 113
  • Thanks! I don't check stack overflow very often, so I didn't see this until just now. Accepted! – Timothy Jones Mar 31 '17 at 02:55
  • It might be worth mentioning that 16.8 supports restrict keyword, even when the default of C89+partial C99 is used. This is a potentially confusing situation as VS2017 and VS2019 prior to 16.8 did not support it. Microsoft confirms that /std:c17 enables support for it, but doesn't tell you it is supported without it, too. – Dan Sep 01 '21 at 18:44
9

I believe that the only non-library language feature of C99 (that's not in C90) supported in MSVC is // comments. 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. For example, you got stdint.h in VS 2010 because it was in the C++ TR1 draft.

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

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. Personally, I'd find it very helpful if just the C99 ability to mix statements with declarations were supported when compiling C code.

But it seems that the language features you see in C with MSVC today is what you'll get from here on.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
  • Thanks, +1. Did you mean that `//` comments are the only non-library C99 feature **supported in Visual Studio**? Do you know if the library headers such as `stdint.h` work in C mode? – Timothy Jones Mar 08 '12 at 00:27
  • "supported in Visual Studio" - yes. I'll update the question to clarify that. And the few times I've used the MSVC-provided C99 library headers in C mode, they've worked fine. – Michael Burr Mar 08 '12 at 01:23
  • 2
    Another update: the quote above indicates that "variadic macros" and "long long" are also in MSVC - I had forgotten about `long long`. I haven't use variadic macros myself, so I'm not sure if they work the same way in MSVC as C99 specifies. The other C99 features mentioned in the quote `__pragma`, `__FUNCTION__`, and `__restrict` are similar, but not quite the same as, the C99 constructs. To use them 'portable' probably requires a bit of annoying macro magic to smooth over the differences (admittedly probably very minor macro magic). – Michael Burr Mar 08 '12 at 01:35