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

How to distinguish between Intel and MSVC in code?

mcarey656
Beginner
454 Views

Is there an easy way (e.g. #ifdef) to distinguish between the Intel Compiler and MSVC in code? I don't want to use #ifdef _WIN32 because I assume both define that.

I need this check because Microsoft does not provide erf(x), which is in tgmath.h.

0 Kudos
3 Replies
JenniferJ
Moderator
454 Views
Yes, you can use following. Those macros will be defined when using icl to build.
__ICL
__INTEL_COMPILER

Jennifer
0 Kudos
TimP
Honored Contributor III
454 Views
Quoting - mcarey656

Is there an easy way (e.g. #ifdef) to distinguish between the Intel Compiler and MSVC in code? I don't want to use #ifdef _WIN32 because I assume both define that.

I need this check because Microsoft does not provide erf(x), which is in tgmath.h.

Look up the __INTEL_COMPILER among "additional pre-defined macros," described in the .chm help file. As far as I can see, requires support for erf() in various float data types, so that ability to choose whether to use tgmath would satisfy this need. I see this as somewhat unsatisfactory, as few compilers, even among those with , give full C99 support, so you can't depend on __STDC_VERSION__.
The problems in dealing with Microsoft non-support of common C99 features, such as , and the need to switch to C++ for some of them, are annoying. I guess listing the pre-definitions for the compilers you use is as good as anything available, where that works.
0 Kudos
mcarey656
Beginner
454 Views
Quoting - tim18
The problems in dealing with Microsoft non-support of common C99 features, such as , and the need to switch to C++ for some of them, are annoying. I guess listing the pre-definitions for the compilers you use is as good as anything available, where that works.

Great, thanks! And yes, Microsoft's non-support of C99 is one of the reasons I'm using Intel in the first place.

0 Kudos
Reply