Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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

NOTE:
This topic contains documentation for the Intel® C++ Compiler Classic. For information on predefined macros for the Intel® C++ Compiler and Intel® DPC++ Compiler, visit Predefined Macros for Intel® Compilers.

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:

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