From 930319633dc27c6d2eebe0257960bb61a3f38233 Mon Sep 17 00:00:00 2001 From: YunchengLiu Date: Tue, 18 Oct 2022 09:31:16 +0800 Subject: [PATCH] Simplify predicates in #2517 for fmtlib 9.1.x macros and the MSVC compiler and wchar filename support macros --- include/spdlog/sinks/daily_file_sink.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index c1f161af..f6f1bb1d 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -77,18 +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 -# if FMT_VERSION >= 90101 - // fmt 9.1.x added compile-time checks for wide strings - // so when compiled with MSVC and this or later version of fmt - // here should use 'SPDLOG_FMT_RUNTIME' to enable 'fmt::runtime(...)' for wchar to avoid compile error - return fmt::format(SPDLOG_FMT_RUNTIME(fmt_filename), now_tm); -# else - return fmt::format(fmt_filename, now_tm); -# endif + + // 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 }