1

To know C++ standard that Visual Studio 2010 uses, I do this:

std::cout << __cplusplus;

the result is 199711 so C++ standard is C++98.

What is the similar way to know C standard of Visual Studio 2010 ?

Edit: I had read old posts about C/C++ standard of VS2010 and I knew VS2010 does not support C99 but these posts didn't mention the answer for my question.

Van Tr
  • 5,889
  • 2
  • 20
  • 44
  • Did you try checking the value of \_\_STDC\_VERSION\_\_? Oh, and first check if \_\_STDC\_\_ is even defined. – 2501 Feb 14 '16 at 13:30
  • @2501 __STDC_VERSION__ is undefined – Van Tr Feb 14 '16 at 13:32
  • Possible duplicate of [Does Microsoft visual studio 2010 support c99?](http://stackoverflow.com/questions/6688895/does-microsoft-visual-studio-2010-support-c99) – Bo Persson Feb 14 '16 at 13:33
  • 1
    It is actually C++03, not changing the number tends to happen with companies with a 1-800 support phone number. 2010 implements C89. – Hans Passant Feb 14 '16 at 13:35
  • @BoPersson no. I read them. What I asked is the similar way to print the standard similar to cout<<__cplusplus – Van Tr Feb 14 '16 at 13:36
  • 2
    @IlDivin - In 1989 there wasn't any need to differentiate between different standards, so no such feature was added. VS2015 is *approaching* C99, that's how far MS has come. – Bo Persson Feb 14 '16 at 13:40

1 Answers1

3

At this point, if _MSC_VER is defined, assume only C89 support. None of Microsoft's compilers officially support beyond the C89 standard. Back in 1989, when the ANSI C standard was first released, there was no reason to check and see what version of it was supported—there was only one version. The designation C89 is itself a neologism.

If Bo's comment is right about VS 2015 approaching C99 support (I'm not sure, I haven't installed VS 2015, and you don't seem to care about that version in the question, either), you could test _MSC_VER for 1900 to detect that version.

That's what you would have to do even if the compiler supported a predefined macro like __STDC_VERSION__ because they're not going to (at least, they're not supposed to) increment the version number until they have full support for the applicable standard. In other words, adding a few of C99's features wouldn't be enough to increment __STDC_VERSION__.

Community
  • 1
  • 1
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574