Skip to content

Commit a61bc88

Browse files
peffgitster
authored andcommitted
CodingGuidelines: mention -Wunused-parameter and UNUSED
Now that -Wunused-parameter is on by default for DEVELOPER=1 builds, people may trigger it, blocking their build. When it's a mistake for the parameter to exist, the path forward is obvious: remove it. But sometimes you need to suppress the warning, and the "UNUSED" mechanism for that is specific to our project, so people may not know about it. Let's put some advice in CodingGuidelines, including an example warning message. That should help people who grep for the warning text after seeing it from the compiler. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a219a67 commit a61bc88

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Documentation/CodingGuidelines

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ For C programs:
258258
ensure your patch is clear of all compiler warnings we care about,
259259
by e.g. "echo DEVELOPER=1 >>config.mak".
260260

261+
- When using DEVELOPER=1 mode, you may see warnings from the compiler
262+
like "error: unused parameter 'foo' [-Werror=unused-parameter]",
263+
which indicates that a function ignores its argument. If the unused
264+
parameter can't be removed (e.g., because the function is used as a
265+
callback and has to match a certain interface), you can annotate the
266+
individual parameters with the UNUSED keyword, like "int foo UNUSED".
267+
261268
- We try to support a wide range of C compilers to compile Git with,
262269
including old ones. As of Git v2.35.0 Git requires C99 (we check
263270
"__STDC_VERSION__"). You should not use features from a newer C

0 commit comments

Comments
 (0)