Files
mp-units/docs/getting_started/cpp_compiler_support.md
T
2026-06-03 21:29:55 +02:00

4.9 KiB

C++ compiler support (API/ABI)

!!! info

**mp-units** library tries to provide the best user experience possible with the C++ language.
To achieve that, it extensively uses the latest C++ language features.

Even though the library benefits from the latest C++ versions (if available), C++20 is enough
to compile and use all of the library's functionality. Newer features can be hidden behind
some [preprocessor macros](../how_to_guides/integration/wide_compatibility.md#using-compatibility-macros)
providing a backward-compatible way to use them.

The table below provides the minimum compiler version required to compile the code using a specific C++ feature:

C++ Feature C++ version gcc clang apple-clang MSVC
Minimum support 20 12+ 16+ && !19 15-16 && !17.0 19.5+
std::format 20 13+ 17+ 16+ 19.5+
C++ modules 20 None 17+ None None
import std; 23 15+ 18+ None 19.5+
Explicit this parameter 23 14+ 18+ 17+ 19.5+

??? note "Clang-19 unfixable bug"

Unfortunately, Clang-19 does not build **mp-units** because of an
[unfixable bug in the compiler](https://github.com/llvm/llvm-project/pull/118288).

??? note "Apple Clang-17.0 unfixable bug"

Unfortunately, Apple Clang-17.0 (Xcode 16.3, 16.4, 26.0, 26.0.1, 26.1, and 26.2-beta) does not
build **mp-units** because it has the same
[unfixable bug as Clang-19](https://github.com/llvm/llvm-project/pull/118288).

!!! important

Enabling/disabling features listed above may influence the API of the library and the ABI of
the customers' projects.

std::format

C++ modules

  • Provide new way to share declarations and definitions across translation units.
  • If used, the library will distribute both "old-style" headers and module interface units
    • associated with the same CMake targets.
  • Even with full compiler support, a user may still decide to not pay for C++ modules compilation if they are not needed by the customer's project.
  • Feature test macro is not used for testing here because even if the compiler does not support the entire C++ feature (e.g. header units), it is enough to build modules for this library.
  • Related build options:

!!! note

More requirements for C++ modules support can be found in the
[CMake's documentation](https://cmake.org/cmake/help/latest/manual/cmake-cxxmodules.7.html).

import std;

  • If enabled, the library will obtain all the definitions from the std namespace via import std; instead of the "old-style" header includes.
  • Related build options:

Explicit this parameter

*[CRTP]: Curiously Recurring Template Parameter