Does Visual Studio 2017 fully support C99?

12,196

Solution 1

No.

https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance

The compiler’s support for C99 Preprocessor rules is incomplete in Visual Studio 2017. Variadic macros are supported, but there are many bugs in the preprocessor’s behavior.

https://docs.microsoft.com/en-us/cpp/build/walkthrough-compile-a-c-program-on-the-command-line

The Visual C++ C compiler is generally compatible with the ISO C99 standard, but not strictly compliant. In most cases, portable C code will compile and run as expected. Visual C++ does not support most of the changes in ISO C11. Certain library functions and POSIX function names are deprecated by the Visual C++ compiler. The functions are supported, but the preferred names have changed. For more information, see Security Features in the CRT and Compiler Warning (level 3) C4996.

Remember that Visual C++ is ultimately a C++ implementation and not a true C environment. The compatibility is a nice side-effect of C and C++’s shared heritage but despite superficial syntactical similarities the two are very different languages.

Solution 2

Largely, yes, although some core language features are implemented non-compliantly (some with bugs and some are missing)

  • Variable Length Arrays are not supported (although these are now officially optional)
  • restrict qualifier is not supported, __restrict is supported instead, but it is not exactly the same
  • Top-level qualifiers in array declarations in function parameters are not supported (e.g. void foo(int a[const])) as well as keyword static in the same context

However, each new version of Visual Studio brings improvements in C99 support, so this work is not frozen apparently.

Answer to this question from 2015 has a number of relevant links, including MS roadmap for C support.

Share:
12,196
user200783
Author by

user200783

Updated on June 03, 2022

Comments

  • user200783
    user200783 about 2 years

    Recent versions of Visual Studio have seen improving support for C99. Does the latest version, VS2017, now support all of C99?

    If not, what features of C99 are still missing?

  • Jonathan Leffler
    Jonathan Leffler over 6 years
    In C99,VLA support is not optional. In C11, it is optional.
  • Royi
    Royi almost 6 years
    Could you elaborate on the difference between restrict and __restrict as implemented by VS?
  • annoying_squid
    annoying_squid almost 5 years
    I really don't understand what the big freaking deal is with these Microsoft people. Is it really that hard for a multi-billion dollar corporation just to add measly support for C99? Talk about a bunch C++ elitists.
  • Bruce Adams
    Bruce Adams over 4 years
    A notable absence is _Complex
  • supercat
    supercat over 4 years
    @annoying_squid: I'd rather have a compiler vendor invest effort in reliably supporting the constructs I need than one that I'd have no interest in using even if supported. Further, while its definition of __restrict doesn't propagate the notion of "based upon", the way C99 defines "based upon" has so many corner cases that are goofy, ambiguous, nonsensical, and unworkable that I wouldn't really fault a compiler vendor for refusing to try to implement it until the authors of the Standard come up with something sensible.