From 2057701d02bffb7c71ce41ae6697064cdc5fa66b Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 23 Jun 2021 10:33:35 -0600 Subject: [PATCH] suppress unused variable warnings An arguably better method for suppressing unused variable warnings. The `(void)var` method does not work on many intel compiilers. This is from Herb Sutter's blog post https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/ --- include/fmt/core.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 14e8c914..dc0d840d 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -332,6 +332,11 @@ struct monostate { constexpr monostate() {} }; +// Eliminate "unused variable" warnings on all compilers. The `(void)var` method +// does not work on many intel compilers. This is from Herb Sutter, "Shutting +// up compiler warnings", https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/ +template void ignore_unused( const T& ) { } + // An enable_if helper to be used in template parameters which results in much // shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed // to workaround a bug in MSVC 2019 (see #1140 and #1186). @@ -2731,7 +2736,7 @@ void check_format_string(S format_str) { remove_cvref_t...>; FMT_CONSTEXPR bool invalid_format = (parse_format_string(s, checker(s, {})), true); - (void)invalid_format; + ignore_unused(invalid_format); } template