Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
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® 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® DPC++ Compiler

  • SYCL_LANGUAGE_VERSION
  • __INTEL_LLVM_COMPILER
  • __VERSION

SYCL_LANGUAGE_VERSION is defined in SYCL specification and should be defined by all SYCL compilers.

__INTEL_LLVM_COMPILER is used to select the compiler.

__VERSION is used to select the compiler version.

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

The following example uses #if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER) to define a code block specific to the Intel® DPC++ Compiler:

#if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)
   // code specific for Intel 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:

Linux

SYCL_LANGUAGE_VERSION: 202001

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, gcc 4.2.1 mode

Windows

SYCL_LANGUAGE_VERSION: 202001

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, clang 12.0.0

Predefined Macros for Intel® C++ Compiler

The following example uses #if !defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER) to define a code block specific to the Intel® C++ Compiler:

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

Linux

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, gcc 4.2.1 mode

Windows

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, clang 12.0.0