A value of predefined macro __cplusplus is still 199711L - by Barfy

Status : 

  Deferred<br /><br />
		The product team has reviewed this issue and has deferred it for consideration at a later time.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 763051 Comments
Status Closed Workarounds
Type Bug Repros 14
Opened 9/17/2012 7:47:02 AM
Access Restriction Public


There is some new code (for example, in recent versions of boost) that uses the value of this macro to test if some new features of STL are available. 

Although MSDN seems to mention only existence of definition of this macro in C++ code, it actually has a value of 199711L, which, I suppose, means some very old version of C++ standard.
Sign in to post a comment.
Posted by Rudolf Grauberger on 8/13/2017 at 5:47 PM
Hi, sorry but this can't very hard fix for you. It help us to work and compile on projects for multi platforms.
Posted by Francisco Areas Guimaraes on 8/11/2017 at 10:33 AM
HI, this is written in 2017 and this is still a problem. I have project that is compiled in multiple platforms, and we use VS to compile the windows part. I use __cplusplus version to check if nullptr is already defined. Please fix this
Posted by Barfy on 6/21/2017 at 5:23 AM
It's OK because for C++ Linux project thay use clang as a front-end compiler and front-end compiler is resolving predefined macros. MSVC's front-end compiler still provides old value for this macro.
Posted by Valera_ on 6/21/2017 at 5:06 AM
Ha-ha-ha...It is OK with C++ Linux project under VS 2017 :) Why it is bad for Windows projects? Is it too lazy to fix?
Posted by Valera_ on 5/31/2017 at 8:40 AM
The same problem for Visual Studio 2017 Enterprise v15.2 [26430.12] (the latest update)
Posted by Valera_ on 5/15/2017 at 2:37 AM
Moderators / Administrators OPEN this #763051 . Should I create MS support ticket (I have subscriptions & licenses) for common bug of VISUAL STUDIO 2015-2017 ?

PS The same problem for Visual Studio 2017 Enterprise v15.2 [26430.6] (the latest update)
I do not want write code like : /*#if (_MSC_VER >= 1900) || (__cplusplus>=201402L)*/ as workaround for @-std=c++14@

Posted by Valera_ on 5/11/2017 at 3:56 AM
It broke C++11 :
"FAQ: What is the value of __cplusplus for C++11? 
 In C++11 the macro __cplusplus is set to the value 201103L. (Before C++11, it was 199711L.)" https://isocpp.org/wiki/faq/cpp11-language-misc

In C++11 the macro __cplusplus will be set to a value that differs from (is greater than) the current 199711L. " http://www.stroustrup.com/C++11FAQ.html

As example Xcode 8 DOES NOT have this MS VS compiler bug and assigned a new value.
Posted by Valera_ on 5/10/2017 at 7:50 AM
Write detailed explanation why bug status is "Closed as Deferred" for all modern VS ?
Posted by Valera_ on 5/10/2017 at 7:32 AM
The same problem for Visual Studio 2017 Enterprise v15.2 (26430.4) (the latest update)

PS Ha-ha-ha, v15.0 -> V15.1 -> v15.2 should be on the first step of "Tools -> Extensions and Updates ->Updates": Now v15.0 does not show any info about v15.2 (!).
Posted by Valera_ on 5/10/2017 at 7:12 AM
The same problem for Visual Studio 2017 Enterprise v15.1 (26403.7) (the latest update)
Posted by Valera_ on 5/10/2017 at 6:21 AM
The same problem for Visual Studio 2017 Enterprise /15.0.0+26228.10.
I created new C++ console app project (from VS template).
Posted by Valera_ on 5/10/2017 at 5:58 AM
A added "/std:c++14" - no help
Posted by Valera_ on 5/10/2017 at 5:57 AM
It is a critical bug!

I attached vs2015_cpp11.png : Windows 10 Enterprise + Visual Studio 2015 Enterprise Update 3 , __cplusplus = 199711L (see screenshot).
Posted by kimryo on 1/30/2017 at 1:26 AM
VS2015 have a so damn cool Stone Age compiler...
Posted by Raul Tambre on 10/15/2016 at 4:16 AM
Still an issue on Visual Studio 2015 (MSVC14)
Posted by Cleroth on 1/12/2016 at 12:05 PM
They can't change it until VS fully supports C++11 (or 03...).
Posted by FeanorPk on 5/28/2015 at 12:53 AM
Still reproducible with following:

#if __cplusplus <= 199711L
#error This library needs at least a C++11 compliant compiler

This gives an error on VS 2013, while the code that uses C++11 features is successfully build.
Why this bug is differed at all???
Posted by Quarks on 4/4/2014 at 7:59 PM
This is still a problem with VS2013 as well.

# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)

doesn't work, since _cplusplus is still 199711L.
The only workaround is to check _MSC_VER for VS2013, and continue on.

Is there a reason why _cplusplus is still 199711L ?
Posted by armano_pawel on 10/18/2013 at 10:13 AM
I can confirm this 2.

#if defined(__cplusplus) && __cplusplus == 201103L
Posted by Inge Eivind Henriksen on 1/2/2013 at 4:47 PM
I can confirm this issue. Here is my test code from my VS 2012 C++ project:

#if __cplusplus >= 201103L
#pragma message C++ ISO/IEC 14882:2011 supported by the compiler (informally known as "C++ 11")
#if __cplusplus >= 199711L
#pragma message C++ ISO/IEC 14882:1998 supported by the compiler
#error No C++ support

Compiler output:
"C++ ISO/IEC 14882:1998 supported by the compiler"
Posted by Barfy on 9/21/2012 at 2:09 AM
This can easily be illustrated by compiling the following code:

#if __cplusplus > 199711L
static_assert(false,"__cplusplus is greater than 199711L")
static_assert(false,"__cplusplus is less than or equal to 199711L")

Which results in the following error message:
1>c:\myprojects\cplusplusmacrotest\cplusplusmacrotest\main.cpp(4): error C2338: __cplusplus is less than or equal to 199711L
1>c:\myprojects\cplusplusmacrotest\cplusplusmacrotest\main.cpp(6): fatal error C1004: unexpected end-of-file found

I will also attach a screenshot with Intellisense showing the value of macro.
Posted by Microsoft on 9/21/2012 at 1:42 AM
Thanks for your feedback. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 9/18/2012 at 1:15 AM
Thanks for your feedback. Could you please provide some screenshots to help us better understand this scenario?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 9/17/2012 at 7:52 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)