Skip to content

Commit 729b392

Browse files
bbolligitster
authored andcommitted
Makefile: add a DEVOPTS flag to get pedantic compilation
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>
1 parent 2b647a0 commit 729b392

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ all::
484484
# The DEVELOPER mode enables -Wextra with a few exceptions. By
485485
# setting this flag the exceptions are removed, and all of
486486
# -Wextra is used.
487+
#
488+
# pedantic:
489+
#
490+
# Enable -pedantic compilation. This also disables
491+
# USE_PARENS_AROUND_GETTEXT_N to produce only relevant warnings.
487492

488493
GIT-VERSION-FILE: FORCE
489494
@$(SHELL_PATH) ./GIT-VERSION-GEN

config.mak.dev

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
ifeq ($(filter no-error,$(DEVOPTS)),)
22
CFLAGS += -Werror
33
endif
4+
ifneq ($(filter pedantic,$(DEVOPTS)),)
5+
CFLAGS += -pedantic
6+
# don't warn for each N_ use
7+
CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
8+
endif
49
CFLAGS += -Wdeclaration-after-statement
510
CFLAGS += -Wno-format-zero-length
611
CFLAGS += -Wold-style-definition

0 commit comments

Comments
 (0)