Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

Intel C++ for Windows __cplusplus value

eldiener
New Contributor I
1,212 Views

When I specify the /Qstd=c++0x command line option for Intel C++ on Windows this is the equivalent of C++11 according to documentation at https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-std-qstd. Yet the __cplusplus value for C++11, which is 201103L, is not set but instead the __cplusplus value for C++03, which is 199711L, is set. This seems to me a bug in Intel C++ as a programmer can not rely on the level of the C++ standard in his code by checking the __cplusplus value.

0 Kudos
11 Replies
Viet_H_Intel
Moderator
1,212 Views

What Intel C++ Compiler did you use? Can we have a test case to investigate?

0 Kudos
eldiener
New Contributor I
1,212 Views

It is Intel C++ 19.0. You need a test case to see that __cplusplus is set to 199711L when compiling with the /Qstd=c++0x option ? How about:

#include <iostream>

int main()

{

std::cout << __cplusplus;

}

 

0 Kudos
Viet_H_Intel
Moderator
1,212 Views

C:\temp>cl test.cpp /std:c++14
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27031.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xlocale(319): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
Microsoft (R) Incremental Linker Version 14.16.27031.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj

C:\temp>test.exe
199711
C:\temp>

0 Kudos
eldiener
New Contributor I
1,212 Views

Viet Hoang (Intel) wrote:

C:\temp>cl test.cpp /std:c++14
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27031.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xlocale(319): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
Microsoft (R) Incremental Linker Version 14.16.27031.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj

C:\temp>test.exe
199711
C:\temp>

Are you trying to tell me that because Microsoft C++ puts out an incorrect value for __cplusplus when compiling at the C++14 level that Intel C++ must also put out the same incorrect value for __cplusplus when compilng at the C++11 level, which C++ level incidentally the Microsoft C++ compiler does not implement at all ?

 

0 Kudos
Viet_H_Intel
Moderator
1,212 Views

No, that is not my intend. Both compiler gave the wrong values.

0 Kudos
Viet_H_Intel
Moderator
1,212 Views

I also reported this bug to our Frontend Engineers.

0 Kudos
Viet_H_Intel
Moderator
1,212 Views

I got some feedback from our Developer:

The latest MSVC++ compiler, MSVC++ 2019 uses that value by default even in /std=c++17 mode.
If you want a more accurate value you need to use the /Zc:__cplusplus switch as described in this
Microsoft blog: https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/

0 Kudos
eldiener
New Contributor I
1,212 Views

Viet Hoang (Intel) wrote:

I got some feedback from our Developer:

The latest MSVC++ compiler, MSVC++ 2019 uses that value by default even in /std=c++17 mode.
If you want a more accurate value you need to use the /Zc:__cplusplus switch as described in this
Microsoft blog: https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/

I am totally aware of how VC++ works in relation to __cplusplus and the /Zc:__cplusplus option. But what does this have to do with Intel C++ ? Does Intel C++ try to replicate this behavior ? If that is the case there is no documentation that Intel C++ has a /Zc:__cplusplus option. If that is not the case then my original report of a bug is correct.

0 Kudos
Viet_H_Intel
Moderator
1,212 Views

Seems like info regarding /Zc:__cplusplus option is missing in the /help section.  

0 Kudos
eldiener
New Contributor I
1,212 Views

Viet Hoang (Intel) wrote:

Seems like info regarding /Zc:__cplusplus option is missing in the /help section.  

Yes, it is missing also in the docs. It appears that /Zc:__cplusplus is valid for Intel 19.0 with vc++14.2 compatibility and Intel 18.0 with vc++14.1 compatibility. I did not try it with Intel 17.0 with vc++ 14.0 compatibility because vc++ 14.0 does not providce the /Zc:__cplusplus option. For Intel 18.0 and Intel 19.0 the value of __cplusplus when using the /Zc:__cplusplus option shows C++14 (201402L). The problem is discerning what the level of C++ standard level is by default in Intel C++ versions where the /Zc:__cplusplus is not available since the __cplusplus value always shows C++03 (199711L) in that case. The documentation does not tell me anywhere what the default level of the C++ standard is in those versions. It probably should say so somewhere in the Intel C++ compiler docs rather than leave the programmer to guess at it or use the undocumented /Zc:__cplusplus compiler option when available.

0 Kudos
Viet_H_Intel
Moderator
1,212 Views

Thanks. Let me work with our doc team to have it updated.

0 Kudos
Reply