From fb6348822bc37391fd323fb62ecf0f0757b928f4 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 13 Feb 2026 05:35:15 -0700 Subject: [PATCH] Fix error: format string is not a string literal (#2126) For some reasons, `std::string StrFormat(const char* format, ...)` was declared with castom format attributes in conditions. The project wide macro `PRINTF_FORMAT_STRING_FUNC` must be used. --- src/string_util.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/string_util.h b/src/string_util.h index f1e50be4f4..7a2ce0ba79 100644 --- a/src/string_util.h +++ b/src/string_util.h @@ -16,13 +16,7 @@ BENCHMARK_EXPORT std::string HumanReadableNumber(double n, Counter::OneK one_k); BENCHMARK_EXPORT -#if defined(__MINGW32__) -__attribute__((format(__MINGW_PRINTF_FORMAT, 1, 2))) -#elif defined(__GNUC__) -__attribute__((format(printf, 1, 2))) -#endif -std::string -StrFormat(const char* format, ...); +std::string StrFormat(const char* format, ...) PRINTF_FORMAT_STRING_FUNC(1, 2); inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT { return out;