spdlog icon indicating copy to clipboard operation
spdlog copied to clipboard

FMT_STRING issue w/ clang, spdlog 1.15.1 and external fmt 11.1.3

Open abrownsword opened this issue 11 months ago • 6 comments

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.

abrownsword avatar Feb 01 '25 17:02 abrownsword

What would be the fix ?

gabime avatar Feb 01 '25 17:02 gabime

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.

abrownsword avatar Feb 01 '25 22:02 abrownsword

It works as long as there are params. Not related to direct uses. Fwiw “replace all” works pretty well with any IDE :)

gabime avatar Feb 01 '25 22:02 gabime

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.

abrownsword avatar Feb 01 '25 22:02 abrownsword

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

gabime avatar Feb 01 '25 22:02 gabime

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.

abrownsword avatar Feb 02 '25 23:02 abrownsword