Home Dashboard Directory Help
Search

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


Status: 

Closed
 as Deferred Help for as Deferred


11
0
Sign in
to vote
Type: Bug
ID: 763051
Opened: 9/17/2012 7:47:02 AM
Access Restriction: Public
0
Workaround(s)
view
7
User(s) can reproduce this bug

Description

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.
Details
Sign in to post a comment.
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__)
...
#endif

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
# define COMPILER_HAS_CPP11_SUPPORT 1
#else
# define COMPILER_HAS_CPP11_SUPPORT 0
#endif
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")
#else
#if __cplusplus >= 199711L
#pragma message C++ ISO/IEC 14882:1998 supported by the compiler
#else
#error No C++ support
#endif
#endif

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")
#else
static_assert(false,"__cplusplus is less than or equal to 199711L")
#endif

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)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
__cplusplusmacro.png 9/21/2012 3 KB
__cplusplusmacro.png 9/21/2012 3 KB