CCCL_HOST_COMPILER#

CCCL_HOST_COMPILER(...)#

Detect the current host compiler and optionally compare its version.

The macro supports the following forms:

For supported host compilers, the macro expands to an implementation-defined true value if the current host compiler and optional version comparison match, or false otherwise. These values may be used in boolean expressions (preprocessor or otherwise), but no other guarantees are made.

Available values for COMPILER include:

  • NVHPC: NVIDIA HPC C++ compiler.

  • CLANG: Clang.

  • GCC: GCC.

  • MSVC: Microsoft Visual C++.

  • MSVC2019: Microsoft Visual C++ 2019.

  • MSVC2022: Microsoft Visual C++ 2022.

  • MSVC2026: Microsoft Visual C++ 2026.

Example
#if CCCL_HOST_COMPILER(GCC)
  // GCC-only code
#endif

#if CCCL_HOST_COMPILER(MSVC, >=, 19, 35)
  // MSVC 2019 or newer code
#endif

Note

This macro is made available when including any libcu++ header. Users that wish to include the smallest possible header for this macro should include <cuda/std/version>.

Warning

When used without specifying a minor version, the macro compares only the compiler’s major version. For example, when the compiler is GCC 9.1, CCCL_HOST_COMPILER(GCC, >, 9) is false even though version 9.1 is greater than 9.

Warning

Passing any other value will result in an undefined expansion, which may or may not be diagnosed by the compiler.

In addition, the macro is intended to support all host compilers that are supported by CUDA Toolkit. See the Host Compiler Support Policy for

Linux and Windows for more details.

Returns:

true if the specified host compiler and optional version comparison match, false otherwise.