From 6c3d584e67088c9add8288863241ac748146e539 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 14 Jun 2019 13:03:34 -0700 Subject: [PATCH] Simplify warning suppression --- include/fmt/format-inl.h | 6 ++++-- include/fmt/format.h | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 96e9cd73..647dc990 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -247,8 +247,10 @@ template <> FMT_FUNC int count_digits<4>(internal::uintptr n) { template int format_float(char* buf, std::size_t size, const char* format, int precision, T value) { - return precision < 0 ? FMT_SNPRINTF(buf, size, format, value) - : FMT_SNPRINTF(buf, size, format, precision, value); + // Suppress the warning about nonliteral format string. + auto snprintf_ptr = FMT_SNPRINTF; + return precision < 0 ? snprintf_ptr(buf, size, format, value) + : snprintf_ptr(buf, size, format, precision, value); } template diff --git a/include/fmt/format.h b/include/fmt/format.h index d6130983..9378f7a9 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -70,10 +70,6 @@ // Disable the warning about declaration shadowing because it affects too // many valid cases. # pragma GCC diagnostic ignored "-Wshadow" - -// Disable the warning about nonliteral format strings because we construct -// them dynamically when falling back to snprintf for FP formatting. -# pragma GCC diagnostic ignored "-Wformat-nonliteral" #endif #if FMT_CLANG_VERSION