From 3c0e036cc9e12664e2b757fd17fdba42f6f19f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=80=98=E5=91=88?= <40971483+YunchengLiu@users.noreply.github.com> Date: Thu, 20 Oct 2022 07:11:16 +0800 Subject: [PATCH] Use 'SPDLOG_FMT_RUNTIME' to fix compilation error throwed MSVC and fmt 9.1.x (#2517) * Use 'SPDLOG_FMT_RUNTIME' to fix compilation error throwed MSVC and fmt 9.1.x * Fix #2512 --- include/spdlog/sinks/daily_file_sink.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index b07b771d..f6f1bb1d 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -77,11 +77,14 @@ struct daily_filename_format_calculator #else // generate fmt datetime format string, e.g. {:%Y-%m-%d}. filename_t fmt_filename = fmt::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{{:{}}}")), filename); -# if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) // for some reason msvc doesn't allow fmt::runtime(..) with wchar here + + // MSVC doesn't allow fmt::runtime(..) with wchar, with fmtlib versions < 9.1.x +# if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) && FMT_VERSION < 90101 return fmt::format(fmt_filename, now_tm); # else return fmt::format(SPDLOG_FMT_RUNTIME(fmt_filename), now_tm); # endif + #endif }