Configuration Macros
The configuration macros below are defined automatically once any library header (for example <boost/int128.hpp>) is included; there is no separate configuration header to include directly.
User Configurable Macros
These macros allow customization of library behavior. User-configurable macros should be defined before including any library headers.
-
BOOST_INT128_ENABLE_CUDA: Defining this macro allows both types and selected functions to be run on both host and device when compiling with NVCC. Allowed functions haveBOOST_INT128_HOST_DEVICEas part of their function signature in their documentation.
-
BOOST_INT128_ENABLE_SYCL: Defining this macro allows both types and selected functions to be run on the device when compiling with a SYCL compiler (for example Intel oneAPIicpx -fsycl). Unlike CUDA, SYCL device support is opt-in and is not detected automatically, so this macro must be defined and<sycl/sycl.hpp>must be included before any Boost.int128 header (so thatSYCL_EXTERNALis available). Device-enabled functions haveBOOST_INT128_HOST_DEVICEas part of their function signature in their documentation. Theboost::charconv::to_chars/from_charsoverloads in<boost/int128/charconv.hpp>also run on the SYCL device: definingBOOST_INT128_ENABLE_SYCLforwards toBOOST_CHARCONV_ENABLE_SYCL, and Boost.Charconv provides matching SYCL device support (as it does for CUDA).
-
BOOST_INT128_NO_BUILTIN_INT128: The user may define this when they do not want the internal implementations to rely on builtin__int128orunsigned __int128types.
-
BOOST_INT128_DISABLE_EXCEPTIONS: Allows exceptions to be disabled. This macro will automatically be defined in the presence of-fno-exceptionsor similar MSVC flags.
-
BOOST_INT128_BUILD_MODULE: Define this when building the library as a C++20 named module (consumed viaimport boost.int128). It switches the headers into module mode by exporting the public interface and suppressing the includes that the module unit itself provides. See Getting Started.
Automatic Configuration Macros
-
BOOST_INT128_HAS_INT128: This is defined when compiling on a platform that has builtin__int128orunsigned __int128types (e.g.__x86_64__). -
BOOST_INT128_ENDIAN_LITTLE_BYTE: This is defined to1when compiling on a little endian architecture, otherwise0. -
BOOST_INT128_ENDIAN_BIG_BYTE: This is defined to1when compiling on a big endian architecture, otherwise0. -
BOOST_INT128_HAS_MSVC_INT128: This is defined when the MSVC standard library provides the simulated 128-bit integer types in<__msvc_int128.hpp>(MSVC in C++20 mode). When defined, the library uses those types as its native 128-bit backing. -
BOOST_INT128_HAS_GPU_SUPPORT: This is defined when the library is compiled with device support enabled, that is under eitherBOOST_INT128_ENABLE_CUDA(with NVCC) orBOOST_INT128_ENABLE_SYCL. It is the single check for whether a GPU device target is in play. Note that on the SYCL device pass the library falls back to its portable path because the spir64 target has no native__int128, soBOOST_INT128_HAS_INT128is not defined there. -
BOOST_INT128_HAS_SPACESHIP_OPERATOR: This is defined when the compiler and standard library provide C++20 three-way comparison (operator<⇒and<compare>). When defined, both types provideoperator<⇒. -
BOOST_INT128_HAS_FORMAT: This is defined by<boost/int128/format.hpp>when C++20<format>is available. When defined, that header providesstd::formatterspecializations for both types. -
BOOST_INT128_HAS_FMT_FORMAT: This is defined by<boost/int128/fmt_format.hpp>when the {fmt} library is available. When defined, that header providesfmt::formatterspecializations for both types.
-
BOOST_INT128_HOST_DEVICE: This is defined to__host__ __device__when compiling for CUDA (__CUDACC__withBOOST_INT128_ENABLE_CUDA), toSYCL_EXTERNALwhen compiling for SYCL (BOOST_INT128_ENABLE_SYCL), and to nothing otherwise. The core type operations (constructors, conversion operators, and the comparison, bitwise, arithmetic, and shift operators) and most free functions are annotated with this macro, allowingint128_tanduint128_tto be used in CUDA and SYCL device code. Host-only integrations that depend on host facilities are not annotated:std::hash, the iostream operators, thestd::formatter/ {fmt} support, and thecore::string_viewoverloads offrom_chars. Under SYCL theoperator long doubleconversion is additionally unavailable because the spir64 device target has nolong double.