mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
998 stars 79 forks source link

fix: work around undefined __cpp_lib_format #444

Closed JohelEGP closed 1 year ago

JohelEGP commented 1 year ago

Uncomment // #include <format> to see how it works at https://compiler-explorer.com/z/oecsc9fje.

gitpod-io[bot] commented 1 year ago

mpusz commented 1 year ago

Do you have any ideas on how to set a default in Conan?

https://github.com/mpusz/units/blob/97e1425bc570638c5fd57d764c2c2b19fd058552/conanfile.py#L98-L103

JohelEGP commented 1 year ago

No. Is the purpose to enable it on environments that support it? What matters here is the library. Does Conan support accessing their names and versions? Libc++'s support is somewhat conditioned: 1678198402 1678198410 The * reads

The paper is implemented but still marked as an incomplete feature. Not yet implemented LWG-issues will cause API and ABI breakage. Prior to libc++ 15, support is disabled by default and can be enabled with -DLIBCXX_ENABLE_INCOMPLETE_FEATURES=ON when building LLVM. In libc++ 15 and later, this feature can be enabled with the -fexperimental-library compiler flag when using libc++ (see https://libcxx.llvm.org/UsingLibcxx.html#enabling-experimental-c-library-features) -- https://en.cppreference.com/w/cpp/compiler_support

Still, including <format> without -fexperimental-library defines __cpp_lib_format.

JohelEGP commented 1 year ago

I'll open some bug reports and see why it's not in <version>. As it stands, it's hard to check on a module, or impossible due to current limitations. It looks like Libc++'s is intentionally commented out:

# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
// #   define __cpp_lib_format                             202106L
# endif
JohelEGP commented 1 year ago

Looks like I had Clang using Libstdc++ on that CE link. Libc++ doesn't define __cpp_lib_format at all.