diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-09-06 10:38:50 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-09-06 10:38:50 -0700 |
| commit | 4476304a06e6dad284e0d75245cd32f01a01a8c7 (patch) | |
| tree | ca1eed236df5eaef10c2a41eacfd7be10e178da1 /git-compat-util.h | |
| parent | 5ecd5fa58b3315d6bdd6ef9218c7ae442782bc5d (diff) | |
| parent | a051ca5e650138230f3dd61bda911f0f409ebf23 (diff) | |
| download | git-4476304a06e6dad284e0d75245cd32f01a01a8c7.tar.gz | |
Merge branch 'jc/maybe-unused'
Developer doc updates.
* jc/maybe-unused:
CodingGuidelines: also mention MAYBE_UNUSED
Diffstat (limited to 'git-compat-util.h')
| -rw-r--r-- | git-compat-util.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index 71b4d23f03..e4a306dd56 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -195,6 +195,19 @@ struct strbuf; #define _NETBSD_SOURCE 1 #define _SGI_SOURCE 1 +/* + * UNUSED marks a function parameter that is always unused. It also + * can be used to annotate a function, a variable, or a type that is + * always unused. + * + * A callback interface may dictate that a function accepts a + * parameter at that position, but the implementation of the function + * may not need to use the parameter. In such a case, mark the parameter + * with UNUSED. + * + * When a parameter may be used or unused, depending on conditional + * compilation, consider using MAYBE_UNUSED instead. + */ #if GIT_GNUC_PREREQ(4, 5) #define UNUSED __attribute__((unused)) \ __attribute__((deprecated ("parameter declared as UNUSED"))) @@ -649,6 +662,17 @@ static inline int git_has_dir_sep(const char *path) #define RESULT_MUST_BE_USED #endif +/* + * 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__)) #include "compat/bswap.h" |
