From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- .../c/language%2Fattributes%2Fmaybe_unused.html | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 devdocs/c/language%2Fattributes%2Fmaybe_unused.html (limited to 'devdocs/c/language%2Fattributes%2Fmaybe_unused.html') diff --git a/devdocs/c/language%2Fattributes%2Fmaybe_unused.html b/devdocs/c/language%2Fattributes%2Fmaybe_unused.html new file mode 100644 index 00000000..e8af27c7 --- /dev/null +++ b/devdocs/c/language%2Fattributes%2Fmaybe_unused.html @@ -0,0 +1,33 @@ +

C attribute: maybe_unused (since C23) +

Suppresses warnings on unused entities.

+

Syntax

+ +
[[ maybe_unused ]]
[[ __maybe_unused__ ]]

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.

+

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);
+}

See also

+
C++ documentation for maybe_unused
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/language/attributes/maybe_unused +

+
-- cgit v1.2.3