From fab780c196ef5ff9d5ae48e2bb482b6f8d812ab2 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 12 Oct 2023 12:58:05 -0400 Subject: [PATCH] Revert "don't need to inline, simplify to always use FMT_CONSTEXPR if it's defined" This reverts commit 1897f7025d4f2dc9ea5e2ac970ceb08ed993b2cc. --- include/spdlog/common.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 9dfdf6d6..1269c14a 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -70,13 +70,19 @@ #define SPDLOG_CONSTEXPR constexpr #endif -// If building with fmt SPDLOG_CONSTEXPR_FUNC needs to be set the same as FMT_CONSTEXPR -// to avoid situations where a constexpr function in spdlog could end up calling -// a non-constexpr function in fmt depending on the compiler -#ifdef FMT_CONSTEXPR - #define SPDLOG_CONSTEXPR_FUNC FMT_CONSTEXPR -#else +// If building with std::format, can just use constexpr, otherwise if building with fmt +// SPDLOG_CONSTEXPR_FUNC needs to be set the same as FMT_CONSTEXPR to avoid situations where +// a constexpr function in spdlog could end up calling a non-constexpr function in fmt +// depending on the compiler +// If fmt determines it can't use constexpr, we should inline the function instead +#ifdef SPDLOG_USE_STD_FORMAT #define SPDLOG_CONSTEXPR_FUNC constexpr +#else // Being built with fmt + #if FMT_USE_CONSTEXPR + #define SPDLOG_CONSTEXPR_FUNC FMT_CONSTEXPR + #else + #define SPDLOG_CONSTEXPR_FUNC inline + #endif #endif #if defined(__GNUC__) || defined(__clang__)