Development Reference Guides

Contents

Use Predefined Macros for Intel® Compilers

This topic describes macros that affect the various Intel® Compilers.
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

Predefined Macros for Each Compiler

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® DPC++ Compiler
  • SYCL_LANGUAGE_VERSION
  • __INTEL_LLVM_COMPILER
  • __VERSION
SYCL_LANGUAGE_VERSION
is defined in SYCL* spec and should be defined by all SYCL compilers.
__INTEL_LLVM_COMPILER
is used to select the compiler.
Intel® C++ Compiler
  • __INTEL_LLVM_COMPILER
  • __VERSION
__INTEL_LLVM_COMPILER
is used to select the compiler.
__VERSION
is used to select the compiler version.

Predefined Macros for Intel® DPC++ Compiler

See the example below using
#if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)
to define a code block specific to the Intel® DPC++ Compiler:
// dpcpp only #if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER) // code specific for DPC++ compiler below // ... ... // example only std::cout << "SYCL_LANGUAGE_VERSION: " << SYCL_LANGUAGE_VERSION << std::endl; std::cout << "__INTEL_LLVM_COMPILER: " << __INTEL_LLVM_COMPILER << std::endl; std::cout << "__VERSION__: " << __VERSION__ << std::endl; #endif
Example output using the Intel® oneAPI Toolkit Gold release with an Intel DPC++ Compiler patch release of 2021.1.2:
Windows
Linux
SYCL_LANGUAGE_VERSION: 202001 __INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel(R) Clang Based C++, clang 12.0.0
SYCL_LANGUAGE_VERSION: 202001 __INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel(R) Clang Based C++, gcc 4.2.1 mode

Predefined Macros for Intel® C++ Compiler

See the example below using
#if !defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)
to define a code block specific to the Intel® C++ Compiler:
// icx only #if !defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER) // code specific for Intel C++ Compiler below // ... ... // example only std::cout << "__INTEL_LLVM_COMPILER: " << __INTEL_LLVM_COMPILER << std::endl; std::cout << "__VERSION__: " << __VERSION__ << std::endl; #endif
Example output using the Intel® oneAPI Toolkit Gold release with an Intel C++ Compiler patch release of 2021.1.2:
Windows
Linux
__INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel(R) Clang Based C++, clang 12.0.0
__INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel(R) Clang Based C++, gcc 4.2.1 mode

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.