FMT_STRING issue w/ clang, spdlog 1.15.1 and external fmt 11.1.3
In straightforward spdlog-using code (that was changed a couple of years back to use FMT_STRING everywhere), after updating to spdlog 1.15.1 and an external fmt 11.1.3, I'm seeing this across the entire codebase. Building with Clang 19.1.6 set to C++20 using gnu stdlibc++ on Ubuntu 24.04:
error: implicit instantiation of undefined template 'fmt::detail::type_is_unformattable_for<FMT_COMPILE_STRING, char>'
| type_is_unformattable_for<T, char_type> _;
The line of code is (but this occurs identically on several hundred logging calls):
logger->debug(FMT_STRING("my string"));
I have seen various reported issues in fmt & spdlog repos saying this was fixed via issue https://github.com/fmtlib/fmt/issues/4177 ... however I am on the latest code and am still seeing this issue. Removing FMT_STRING at any given callsite eliminates the error, but I'm not excited about making such a sweeping change across the codebase (and it would make reverting much harder). The macro still seems to be supported, however it appears to be broken.
What would be the fix ?
I don't know, but a couple of direct uses of fmt::format(FMT_STRING("..."), ...) in the same file as the above error compile fine.
It works as long as there are params. Not related to direct uses. Fwiw “replace all” works pretty well with any IDE :)
Ah yes, I hadn't noticed that the failure cases were all without args. Perhaps an additional overload of info/debug/warn/etc is required then?
As I mentioned above making a sweeping change increases the difficulty of reverting to an older version if some other issue is discovered.
So perhaps redefine the macro after including spdlog.h or replace all code with custom macro name that does nothing, so it would be easy to revert
Still seems like a bug in spdlog that ought to be fixed (e.g. perhaps by adding an overload with only the format string parameter?), but realizing this only occurs when there are no additional parameters narrowed the problem enough to work around it.