Visible to Intel only — GUID: GUID-7B08EC74-06F4-42A2-A328-6918216451AD
Visible to Intel only — GUID: GUID-7B08EC74-06F4-42A2-A328-6918216451AD
Use Predefined Macros to Specify Intel® Compilers
This topic shows how to use predefined macros to specify an Intel® compiler or version of an Intel compiler.
Predefined Macros to Specify Compiler and Version
When you install both the Intel® oneAPI Base Toolkit (Base Kit) and the Intel® oneAPI HPC Toolkit (HPC Kit), you will notice that there are three compilers installed:
- Intel® DPC++ Compiler
- Intel® C++ Compiler
- Intel® C++ Compiler Classic
You can use the following predefined macros to invoke a specific compiler or version of a compiler:
Compiler | Predefined Macros to Differentiate from Other Compiler | Notes |
---|---|---|
Intel® C++ Compiler Classic |
|
__INTEL_COMPILER is used to select the compiler. __INTEL_COMPILER_BUILD_DATE is used to select the compiler build. |
Predefined Macros for Intel® C++ Compiler Classic
The following example uses #if defined(__INTEL_COMPILER) to define a code block specific to the Intel® C++ Compiler Classic:
// icc/icpc classic only
#if defined(__INTEL_COMPILER)
// code specific for Intel C++ Compiler Classic below
// ... ...
// example only
std::cout << "__INTEL_COMPILER_BUILD_DATE: " << __INTEL_COMPILER_BUILD_DATE << std::endl;
std::cout << "__INTEL_COMPILER: " << __INTEL_COMPILER << std::endl;
std::cout << "__VERSION__: " << __VERSION__ << std::endl;
#endif
Example output using the Intel® oneAPI Toolkit Gold release with an Intel C++ Compiler Classic patch release of 2021.1.2:
Linux
__INTEL_COMPILER_BUILD_DATE: 20201208 __INTEL_COMPILER: 2021 __VERSION__: Intel(R) C++ g++ 7.5 mode
Windows
__INTEL_COMPILER_BUILD_DATE: 20201208 __INTEL_COMPILER: 202110