Skip to content

C++ compiler support (API/ABI)


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 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 15 None
std::format 20 13 17 None None
C++ modules 20 None 17 None None
Static constexpr variables in constexpr functions 23 13 17 None None
Explicit this parameter 23 14 18 None None


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


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:


More requirements for C++ modules support can be found in the CMake's documentation.

Static constexpr variables in constexpr functions

Explicit this parameter