|
11 | 11 | #ifndef __CCCL_COMPILER_H
|
12 | 12 | #define __CCCL_COMPILER_H
|
13 | 13 |
|
| 14 | +#define _CCCL_COMPILER_MAKE_VERSION(_MAJOR, _MINOR) (_MAJOR * 100 + _MINOR) |
| 15 | + |
14 | 16 | // Determine the host compiler and its version
|
15 | 17 | #if defined(__INTEL_COMPILER)
|
16 | 18 | # define _CCCL_COMPILER_ICC
|
|
19 | 21 | "Support for the Intel C++ Compiler Classic is deprecated and will eventually be removed. Define CCCL_SUPPRESS_ICC_DEPRECATION_WARNING to suppress this warning"
|
20 | 22 | # endif // CCCL_SUPPRESS_ICC_DEPRECATION_WARNING
|
21 | 23 | #elif defined(__NVCOMPILER)
|
22 |
| -# define _CCCL_COMPILER_NVHPC |
23 |
| -# define _CCCL_COMPILER_NVHPC_VERSION \ |
24 |
| - (__NVCOMPILER_MAJOR__ * 10000 + __NVCOMPILER_MINOR__ * 100 + __NVCOMPILER_PATCHLEVEL__) |
| 24 | +# define _CCCL_COMPILER_NVHPC _CCCL_COMPILER_MAKE_VERSION(__NVCOMPILER_MAJOR__, __NVCOMPILER_MINOR__) |
25 | 25 | #elif defined(__clang__)
|
26 | 26 | # define _CCCL_COMPILER_CLANG
|
27 | 27 | # define _CCCL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
|
36 | 36 | # define _CCCL_COMPILER_NVRTC
|
37 | 37 | #endif
|
38 | 38 |
|
| 39 | +#define _CCCL_COMPILER_COMPARE_VERSION_1(_COMP) _COMP |
| 40 | +#define _CCCL_COMPILER_COMPARE_VERSION_3(_COMP, _OP, _MAJOR) _CCCL_COMPILER_COMPARE_VERSION_4(_COMP, _OP, _MAJOR, 0) |
| 41 | +#define _CCCL_COMPILER_COMPARE_VERSION_4(_COMP, _OP, _MAJOR, _MINOR) \ |
| 42 | + (_COMP && (_COMP _OP _CCCL_COMPILER_MAKE_VERSION(_MAJOR, _MINOR))) |
| 43 | + |
| 44 | +#define _CCCL_COMPILER_SELECT_COUNT(_ARG1, _ARG2, _ARG3, _ARG4, _ARG5, ...) _ARG5 |
| 45 | +#define _CCCL_COMPILER_SELECT(...) \ |
| 46 | + _CCCL_COMPILER_SELECT_COUNT( \ |
| 47 | + __VA_ARGS__, \ |
| 48 | + _CCCL_COMPILER_COMPARE_VERSION_4, \ |
| 49 | + _CCCL_COMPILER_COMPARE_VERSION_3, \ |
| 50 | + _CCCL_COMPILER_COMPARE_BAD_ARG_COUNT, \ |
| 51 | + _CCCL_COMPILER_COMPARE_VERSION_1, \ |
| 52 | + _CCCL_COMPILER_COMPARE_BAD_ARG_COUNT) |
| 53 | +// Fixme for MSVC without /Zc:preprocessor option |
| 54 | +#define _CCCL_COMPILER(...) _CCCL_COMPILER_SELECT(_CCCL_COMPILER_##__VA_ARGS__)(_CCCL_COMPILER_##__VA_ARGS__) |
| 55 | + |
39 | 56 | // Convenient shortcut to determine which version of MSVC we are dealing with
|
40 | 57 | #if defined(_CCCL_COMPILER_MSVC)
|
41 | 58 | # if _MSC_VER < 1920
|
|
0 commit comments