Skip to content

Commit

Permalink
suppress unused variable warnings (#2381)
Browse files Browse the repository at this point in the history
* 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/

* Format to eliminate long lines

* Run clang-format
  • Loading branch information
gsjaardema authored Jun 30, 2021
1 parent 002bb75 commit fbb70ee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ 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 <class T> 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).
Expand Down Expand Up @@ -2739,7 +2745,7 @@ void check_format_string(S format_str) {
remove_cvref_t<Args>...>;
FMT_CONSTEXPR bool invalid_format =
(parse_format_string<true>(s, checker(s, {})), true);
(void)invalid_format;
ignore_unused(invalid_format);
}

template <typename Char>
Expand Down

0 comments on commit fbb70ee

Please sign in to comment.