From 5a37e182deee09a873777ff3f8e901d117e5f39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= <17547773+HazardyKnusperkeks@users.noreply.github.com> Date: Mon, 21 Dec 2020 17:43:30 +0100 Subject: [PATCH] Disable warning about format string (#2067) Reported by MinGW/GCC 10 --- include/fmt/chrono.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index d68d8c9a..bbb6b502 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -383,12 +383,21 @@ inline std::tm gmtime( namespace detail { inline size_t strftime(char* str, size_t count, const char* format, const std::tm* time) { - return std::strftime(str, count, format, time); + // Assign to a pointer to suppress GCCs -Wformat-nonliteral + // First assign the nullptr to suppress -Wsuggest-attribute=format + std::size_t (*strftime)(char*, std::size_t, const char*, const std::tm*) = + nullptr; + strftime = std::strftime; + return strftime(str, count, format, time); } inline size_t strftime(wchar_t* str, size_t count, const wchar_t* format, const std::tm* time) { - return std::wcsftime(str, count, format, time); + // See above + std::size_t (*wcsftime)(wchar_t*, std::size_t, const wchar_t*, + const std::tm*) = nullptr; + wcsftime = std::wcsftime; + return wcsftime(str, count, format, time); } } // namespace detail