sys/cdefs.h: Introduce __maybe_unused attribute

The __maybe_unused attribute should be used for variables which may or
may not be used, such as when their only use is in an assertion. This
attribute is functionally identical to __unused, suppressing compiler
warnings for particular variable if it remains unused.

Reviewed by:	Minsoo Choo <minsoo@minsoo.io>, imp
Differential Revision:	https://reviews.freebsd.org/D56517
This commit is contained in:
Hans Rosenfeld
2026-04-16 20:22:44 +02:00
committed by Ed Maste
parent 103f9883d1
commit 84a9574180
3 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -3,7 +3,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.Dd May 9, 2025
.Dd May 6, 2026
.Dt CDEFS 9
.Os
.Sh NAME
@@ -85,7 +85,9 @@ linkage.
.It Sy __weak_symbol Ta Declare the symbol to be a weak symbol
.It Sy __dead2 Ta Function will not return
.It Sy __pure2 Ta Function has no side effects
.It Sy __unused Ta To Variable may be unused (usually arguments), so do not
.It Sy __unused Ta Variable may be unused (usually arguments), so do not
warn about it
.It Sy __maybe_unused Ta Variable may be unused (usually arguments), so do not
warn about it
.It Sy __used Ta Function really is used, so emit it even if it appears unused.
.It Sy __deprecated Ta Function interface has been deprecated, and clients