From d55e61f1203e9c75d62467434383e66af0c486ab Mon Sep 17 00:00:00 2001 From: jk-jeon <33922675+jk-jeon@users.noreply.github.com> Date: Thu, 17 Sep 2020 15:21:17 -0700 Subject: [PATCH 1/2] Improve FMT_ALWAYS_INLINE (#1878) 1. FMT_ALWAYS_INLINE should imply inline; otherwise, there might be linkage problems 2. Add specialization for MSVC (__forceinline) --- include/fmt/format.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 98c15c64..2fd6ee1f 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -870,8 +870,10 @@ template <> int count_digits<4>(detail::fallback_uintptr n); #if FMT_GCC_VERSION || FMT_CLANG_VERSION # define FMT_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif FMT_MSC_VER +# define FMT_ALWAYS_INLINE __forceinline #else -# define FMT_ALWAYS_INLINE +# define FMT_ALWAYS_INLINE inline #endif #ifdef FMT_BUILTIN_CLZ From 45da432d60535219284a970be3addbcc1d86b780 Mon Sep 17 00:00:00 2001 From: Jan Schwers Date: Thu, 3 Sep 2020 16:38:35 +0200 Subject: [PATCH 2/2] fix compiler warnings in public header files --- include/fmt/format.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 2fd6ee1f..ca26e772 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1611,7 +1611,7 @@ template struct int_writer { char digits[40]; format_decimal(digits, abs_value, num_digits); basic_memory_buffer buffer; - size += prefix_size; + size += static_cast(prefix_size); const auto usize = to_unsigned(size); buffer.resize(usize); basic_string_view s(&sep, sep_size); @@ -3495,7 +3495,7 @@ inline std::string to_string(T value) { // The buffer should be large enough to store the number including the sign or // "false" for bool. constexpr int max_size = detail::digits10() + 2; - char buffer[max_size > 5 ? max_size : 5]; + char buffer[max_size > 5 ? static_cast(max_size) : 5]; char* begin = buffer; return std::string(begin, detail::write(begin, value)); }