Skip to content

Commit

Permalink
fix: Compatibility with external fmtlib 11.1.1 (#3312)
Browse files Browse the repository at this point in the history
Include fmtlib's `xchar` header to include `fmt::basic_format_string`.
Otherwise, compilation with an external fmtlib 11.1.1 fails with

```
In file included from include/spdlog/spdlog.h:12:
include/spdlog/common.h:369:49: error: no template named 'basic_format_string' in namespace 'fmt'; did you mean 'std::basic_format_string'?
  369 | inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt) {
      |                                                 ^~~~~
```

Signed-off-by: Christian Blichmann <cblichmann@google.com>
  • Loading branch information
cblichmann authored Jan 7, 2025
1 parent 276ee5f commit 7f8060d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions include/spdlog/fmt/fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
#else // SPDLOG_FMT_EXTERNAL is defined - use external fmtlib
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/xchar.h>
#endif

2 comments on commit 7f8060d

@yachoor
Copy link

@yachoor yachoor commented on 7f8060d Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?
The basic_format_string issue was already fixed with parent commit (276ee5f) and including fmt/xchar.h when wchar_t support is not needed was previously declared as unwanted (#3277 (comment)).
Including this file is causing compilation errors on one of gcc toolchains I have to use (probably due to a bug in the toolchain), that I'd rather avoid dealing with if not necessary.

@gabime
Copy link
Owner

@gabime gabime commented on 7f8060d Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes might be unneeded. PR is welcome

Please sign in to comment.