Skip to content

Conversation

@afarber
Copy link
Contributor

@afarber afarber commented Oct 15, 2025

Fix #7260 by addressing two issues:

1. std::format compatibility layer

Adds runtime detection and fallback for C++20 std::format:

  • Add CMake runtime detection using check_cxx_source_runs to test compile, link and execution
  • Create a thin compatibility wrapper include/util/format.hpp
  • Use std::format when available and fully functional
  • Fallback to fmt::format for incomplete implementations (e.g., Clang with older libstdc++ missing symbols)
  • Include <cmath> before <format> to prevent std::isfinite conflicts

2. Fix node_osrm C++ standard mismatch

When #6877 moved the project to C++20 in May 2024, src/nodejs/CMakeLists.txt was overlooked.
This caused node_osrm to be compiled with C++17 while linking against libosrm compiled with C++20,
creating an ABI mismatch. This PR updates node_osrm to C++20 to match the rest of the codebase.

Tasklist

Requirements / Relations

#7251

@afarber afarber changed the title Add std::format compatibility layer with fallback to fmt::format Add std::format compatibility layer and fix node_osrm C++17/C++20 ABI mismatch Oct 18, 2025
@afarber afarber mentioned this pull request Oct 18, 2025
4 tasks
@afarber
Copy link
Contributor Author

afarber commented Oct 19, 2025

Hi @DennisOSRM and @SiarheiFedartsou please review my PR.

It would allow moving users on newer systems to std::format without losing/upsetting users on older systems.

Also it fixes an ABI mismatch, which was causing not found std:: methods errors while I was preparing the PR initially.

@DennisOSRM DennisOSRM merged commit 145f6de into Project-OSRM:master Oct 19, 2025
21 checks passed
@afarber afarber deleted the 7251-use-std-format branch October 19, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use std::format when available, fallback to fmt::format for older compilers

2 participants