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.

Note

Documentation for the Intel® DPC++ Compiler and Intel® C++ Compiler is provided in the Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference. For information on predefined macros for the Intel® C++ Compiler and Intel® DPC++ Compiler, please visit the Use Predefined Macros for Intel® Compilers.

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:

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
  • __INTEL_COMPILER_BUILD_DATE

__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:

Windows Linux
__INTEL_COMPILER_BUILD_DATE: 20201208

__INTEL_COMPILER: 202110
__INTEL_COMPILER_BUILD_DATE: 20201208

__INTEL_COMPILER: 2021

__VERSION__: Intel® C++ g++ 7.5 mode