From 6e6eb63770a8f69bba48d079fb0f43f036d6b543 Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Tue, 7 Feb 2023 16:12:58 -0600 Subject: [PATCH] [msvc] fix warning about non-inline variable --- include/fmt/core.h | 8 +++++++- include/fmt/format.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 6d0bead8..6c9d968b 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -281,6 +281,12 @@ # endif #endif +#if defined __cpp_inline_variables && __cpp_inline_variables >= 201606L +# define FMT_INLINE_VARIABLE inline +#else +# define FMT_INLINE_VARIABLE +#endif + // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") #if !defined(__OPTIMIZE__) && !defined(__NVCOMPILER) && !defined(__LCC__) @@ -2662,7 +2668,7 @@ FMT_CONSTEXPR auto check_char_specs(const format_specs& specs) -> bool { return true; } -constexpr int invalid_arg_index = -1; +constexpr FMT_INLINE_VARIABLE int invalid_arg_index = -1; #if FMT_USE_NONTYPE_TEMPLATE_ARGS template diff --git a/include/fmt/format.h b/include/fmt/format.h index 315644f5..2c4a8b7d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -680,7 +680,7 @@ FMT_CONSTEXPR inline auto utf8_decode(const char* s, uint32_t* c, int* e) return next; } -constexpr uint32_t invalid_code_point = ~uint32_t(); +constexpr FMT_INLINE_VARIABLE uint32_t invalid_code_point = ~uint32_t(); // Invokes f(cp, sv) for every code point cp in s with sv being the string view // corresponding to the code point. cp is invalid_code_point on error.