CCCL_HOST_COMPILER#
-
CCCL_HOST_COMPILER(...)#
Detect the current host compiler and optionally compare its version.
The macro supports the following forms:
CCCL_HOST_COMPILER(COMPILER): Detect whetherCOMPILERis the current host compiler.CCCL_HOST_COMPILER(COMPILER, OP, MAJOR): Compare the compiler’s major version.CCCL_HOST_COMPILER(COMPILER, OP, MAJOR, MINOR): Compare the compiler’s major and minor version.
For supported host compilers, the macro expands to an implementation-defined
truevalue if the current host compiler and optional version comparison match, orfalseotherwise. These values may be used in boolean expressions (preprocessor or otherwise), but no other guarantees are made.Available values for
COMPILERinclude: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)isfalseeven 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:
trueif the specified host compiler and optional version comparison match,falseotherwise.