Does Intel C++ predefine some macro when compiling with Qstd=c++0x? Something like __GXX_EXPERIMENTAL_CXX0X__ in GCC? __cplusplus is still 199711.
Any way to detect C++0x compilation?
The Intel documentation indicates that it does define __GXX_EXPERIMENTAL_CXX0X__ on Linux, but does not define any macro on Windows.
On the current (2013-08-06) Intel Composer XE 2013 Update 5 for Windows, the list of preprocessor definitions includes
#define __INTEL_CXX11_MODE__ 1
if and only if C++0x mode is enabled.
Related
I am attempting to add the numbers header to my program for pi and euler's number, but my C++ version is C++14, and while I've added "-std=c++2a" to tasks.json and changed the C++ standard to C++20 on the "C/C++" extension, the __cplusplus macro still outputs the indicator for C++14. What else should I try in order to enable C++20? Also GCC ver 9.2.0 is being used.
Is the c++ version you use tied to the version of compiler you have or IDE?
If it isn't either of those, how do I use c++ 11 on my IDE? How do i update what C++ version i use in my programs?
How do I check what version I'm using?
I know that printing the __cplusplus variable can tell me what version I'm using, but this doesn't answer my other questions, neither does it answer my third question, because: https://stackoverflow.com/a/14131551/10938047
Found this question, with the answer containing an outdated link.
Visual Studio 2012 __cplusplus and C++ 11
The C++ version you can use is obviously tied to the compiler you use. If your compiler doesn't support some newer standard then of course you cannot use it.
As for IDEs; some IDEs are tied to a specific compiler, some can use different ones.
Some compilers support multiple language versions but require you to explicitly enable anything newer than what they enable by default. For example; most older versions of GCC support C++17 just fine, but default to C++11 or C++14 unless you tell them to enable C++17 support via the -std=c++17 command line option.
MSVC 2019 has added a new _udiv128() intrinsic (documentation)
that I would like to use in my C++ code. However that intrinsic is currently not available in both clang-cl 9.0.0 and the Intel C++ compiler 2019 even though these compilers set _MSC_VER=1920 just like MSVC 2019.
Because of this issue the code below does not compile using both clang-cl and icl:
#include <immintrin.h>
#if _MSC_VER >= 1920
uint64_t res = _udiv128(a, b, c, &d);
#endif
Is there a way to detect MSVC using the preprocessor without detecting clang-cl, icl, ... I would like to avoid checking for _MSC_VER and then excluding all other C/C++ Windows compilers.
Ideally I would like to detect MSVC using a Microsoft specific macro that is only defined for MSVC but not for clang-cl, icl...
I can't speak for the Intel compiler.
Clang-cl defines _MSC_VER because it's trying to be a drop-in replacement for the MSVC compiler and to use the MS libraries that come with the compiler (e.g., the C RTL and the C++ Standard Library). Those library implementations depend on _MSC_VER, so clang-cl doesn't really have an option.
Options:
Seva's proposal from the comments will work for you. I understand is not your preferred solution, but it is an option. You could test it in one place so that you only have to update one place when the situation improves.
Try using the -fms-compatibility-version clang-cl flag to choose an older version. (If you don't provide this flag, clang-cl tries to discover you MSVC installation and then matches the compatibility flag to that installations libraries, which is probably why you're seeing exactly 1920.) This will prevent your #if _MSC_VER >= 1920 from triggering, but it could have side-effects if there are parts of the system libraries that require 1920-or-better.
Wait for clang-cl to implement _udiv128(). Better yet, propose a patch to get it done sooner.
In VS2015 is there an equivalent flag of GCC -fpermissive?
That's for a cpp application
Thanks
S.
VC++ compiler permissive by default, but you can disable it using compiler flag /permissive- starting with VS2015 Update 3
The theoretical equivalent is /Ze.
However, this allows Microsoft-specific extensions, whereas -fpermissive allows GCC-specific extensions. If you want your code to be portable, write portable code. It's that simple.
We recently had a new requirement to use the phonon component of Qt, which on windows requires Visual Studio.
I installed VS2008 and ran a compile. There are a stack of problems due to make not working anything like nmake.
Since I need to maintain cross-platform I want to test which compiler is being used so that I can make changes as required.
An example is that the PRETTY_FUNCTION is a g++ macro with FUNCDNAME being the VC equivalent. How do I test which compiler I am using to determine which macro to call?
Use the _MSC_VER macro. If it is defined, you're using Visual Studio:
#ifdef _MSC_VER
... MSVC code ...
#else
... other compiler ...
#endif