Thread (2 messages) 2 messages, 2 authors, 2024-08-29

Re: [PATCH v2] CodingGuidelines: also mention MAYBE_UNUSED

From: Jeff King <hidden>
Date: 2024-08-29 19:40:55

On Thu, Aug 29, 2024 at 11:18:06AM -0700, Junio C Hamano wrote:
quoted hunk ↗ jump to hunk
+/*
+ * MAYBE_UNUSED marks a function parameter that may be unused, but
+ * whose use is not an error.  It also can be used to annotate a
+ * function, a variable, or a type that may be unused.
+ *
+ * Depending on a configuration, all uses of such a thing may become
+ * #ifdef'ed away.  Marking it with UNUSED would give a warning in a
+ * compilation where it is indeed used, and not marking it at all
+ * would give a warning in a compilation where it is unused.  In such
+ * a case, MAYBE_UNUSED is the appropriate annotation to use.
+ */
 #define MAYBE_UNUSED __attribute__((__unused__))
Thanks, I think this is good. There's more nuanced discussion about when
the "MAYBE" variant could be used for non-parameters, but I don't know
that it's worth trying to enumerate every place we've found it useful.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help