Skip to content

Commit 4550c16

Browse files
peffgitster
authored andcommitted
compat: disable -Wunused-parameter in 3rd-party code
We carry some vendored 3rd-party code in compat/ that does not build cleanly with -Wunused-parameters. We could mark these with UNUSED, but there are two reasons not to: 1. This is code imported from elsewhere, so we'd prefer to avoid modifying it in an invasive way that could create conflicts if we tried to pull in a new version. 2. These files don't include git-compat-util.h at all, so we'd need to factor out (or repeat) our UNUSED macro. In theory we could modify the build process to invoke the compiler with the extra warning disabled for these files, but there are tricky corner cases there (e.g., for NO_REGEX we cannot assume that the compiler understands -Wno-unused-parameter as an option, so we'd have to use our detect-compiler script). Instead, let's rely on the gcc diagnostic #pragma. This is horribly unportable, of course, but it should do what we want. Compilers which don't understand this particular pragma should ignore it (per the standard), and compilers which do care about "-Wunused-parameter" will hopefully respect it, even if they are not gcc (e.g., clang does). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c90b41 commit 4550c16

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

compat/nedmalloc/nedmalloc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ DEALINGS IN THE SOFTWARE.
3131
/*#pragma optimize("a", on)*/
3232
#endif
3333

34+
#pragma GCC diagnostic ignored "-Wunused-parameter"
35+
3436
/*#define FULLSANITYCHECKS*/
3537

3638
#include "nedmalloc.h"

compat/regex/regcomp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
License along with the GNU C Library; if not, see
1818
<http://www.gnu.org/licenses/>. */
1919

20+
#pragma GCC diagnostic ignored "-Wunused-parameter"
21+
2022
#if defined __TANDEM
2123
/* This is currently duplicated from git-compat-utils.h */
2224
# ifdef NO_INTPTR_T

0 commit comments

Comments
 (0)