]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Makefile: add a DEVOPTS flag to get pedantic compilation
authorBeat Bolli <dev+git@drbeat.li>
Tue, 24 Jul 2018 19:26:43 +0000 (21:26 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Jul 2018 16:52:32 +0000 (09:52 -0700)
In the interest of code hygiene, make it easier to compile Git with the
flag -pedantic.

Pure pedantic compilation with GCC 7.3 results in one warning per use of
the translation macro `N_`:

    warning: array initialized from parenthesized string constant [-Wpedantic]

Therefore also disable the parenthesising of i18n strings with
-DUSE_PARENS_AROUND_GETTEXT_N=0.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
config.mak.dev

index e4b503d259906d60a65204248aeb54962b12c062..64aacb360daf68f5b4a41fa756042d3b9728f722 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -484,6 +484,11 @@ all::
 #        The DEVELOPER mode enables -Wextra with a few exceptions. By
 #        setting this flag the exceptions are removed, and all of
 #        -Wextra is used.
+#
+#    pedantic:
+#
+#        Enable -pedantic compilation. This also disables
+#        USE_PARENS_AROUND_GETTEXT_N to produce only relevant warnings.
 
 GIT-VERSION-FILE: FORCE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
index 2d244ca470d8d99f54034b1494127db25c5161ad..9a998149d99a8eeebf311d5e84d43f146ed0f90d 100644 (file)
@@ -1,6 +1,11 @@
 ifeq ($(filter no-error,$(DEVOPTS)),)
 CFLAGS += -Werror
 endif
+ifneq ($(filter pedantic,$(DEVOPTS)),)
+CFLAGS += -pedantic
+# don't warn for each N_ use
+CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
+endif
 CFLAGS += -Wdeclaration-after-statement
 CFLAGS += -Wno-format-zero-length
 CFLAGS += -Wold-style-definition