Emulator Issues #11970
closedfmt 5.3.0 is incompatible with C++20
0%
Description
https://github.com/dolphin-emu/dolphin/tree/master/Externals/fmt is currently version 5.3.0 (released Dec 28, 2018). This version used std::result_of, which was deprecated in C++17 and removed in C++20. MSVC has implemented this removal (by merging https://github.com/microsoft/STL/pull/380 which will ship in VS 2019 16.6 Preview 2 in the near-ish future). This causes Dolphin to fail to build in C++20 mode:
F:\gitP\dolphin-emu\dolphin\Externals\fmt\include\fmt\core.h(202,25): error C2039: 'result_of': is not a member of 'std' [F:\gitP\dolphin-emu\dolphin\Source\Core\Common\Common.vcxproj]
We (the MSVC team) are seeing this because we test a number of open-source projects, including Dolphin, with development builds of the MSVC toolset. This allows us to find and fix bugs in our toolset before they can affect you, and it also allows us to provide advance notice of source-breaking incompatibilities like this one.
Fortunately, the fmt library has already been fixed to deal with the deprecation and removal of std::result_of. (It appears this was https://github.com/fmtlib/fmt/pull/1028 followed by more commits; I don't recommend attempting to port individual patches.) I believe that the first fixed version was fmt 6.0.0 (released Aug 26, 2019), but it would be best to upgrade to the latest release, fmt 6.1.2 (released Dec 11, 2019).
If upgrading the version of fmt used by Dolphin is difficult at this time, MSVC provides "escape hatch" macros that can be defined project-wide to suppress the deprecation warning and restore the removed type trait. (Specifically, compiling with /D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING and /D_HAS_DEPRECATED_RESULT_OF=1 .) However, upgrading fmt is the best solution here.