A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/c/language/attributes/maybe_unused.html below:

C attribute: maybe_unused (since C23)

Suppresses warnings on unused entities.

[edit] Syntax [[ maybe_unused ]]
[[ __maybe_unused__ ]] [edit] Explanation

This attribute can appear in the declaration of the following entities:

If the compiler issues warnings on unused entities, that warning is suppressed for any entity declared maybe_unused.

[edit] Example
#include <assert.h>
 
[[maybe_unused]] void f([[maybe_unused]] _Bool cond1, [[maybe_unused]] _Bool cond2)
{
   [[maybe_unused]] _Bool b = cond1 && cond2;
   assert(b); // in release mode, assert is compiled out, and b is unused
              // no warning because it is declared [[maybe_unused]]
} // parameters cond1 and cond2 are not used, no warning
 
int main(void)
{
    f(1, 1);
}
[edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4