git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] Makefile: add a DEVOPTS flag to get pedantic compilation

From
Beat Bolli <dev+git@drbeat.li>
Date
Jul 24, 2018, 17:13 UTC
Message-ID
<20180724171339.18983-1-dev+git@drbeat.li>
In-Reply-To
<xmqqa7qg22he.fsf@gitster-ct.c.googlers.com>

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=no.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
Now with -DUSE_PARENS_AROUND_GETTEXT_N=0 instead of =No.

This is the convenience knob for all developers that led to the series bb/pedantic[1]. It does not depend on this series, though.

[1] https://public-inbox.org/git/20180708144342.11922-1-dev+git@drbeat.li/T/#u
 Makefile       | 6 ++++++
 config.mak.dev | 5 +++++
 2 files changed, 11 insertions(+)
diff --git a/Makefile b/Makefile
index 0cb6590f24..2bfc051652 100644
--- a/Makefile
+++ b/Makefile
@@ -484,6 +484,12 @@ 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
diff --git a/config.mak.dev b/config.mak.dev
index 2d244ca470..e11dd94741 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -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
-- 
2.18.0.203.gfac676dfb9
Previous: Junio C HamanoNext: Beat Bolli
Message 5 of 8 in “Makefile: add a DEVOPTS flag to get pedantic compilation”
  1. Makefile: add a DEVOPTS flag to get pedantic compilationBeat Bolli, Jul 21, 2018
  2. Junio C HamanoJul 23, 2018
  3. Beat BolliJul 24, 2018
  4. Junio C HamanoJul 24, 2018
  5. Makefile: add a DEVOPTS flag to get pedantic compilationBeat Bolli, Jul 24, 2018
  6. Makefile: add a DEVOPTS flag to get pedantic compilationBeat Bolli, Jul 24, 2018
  7. Junio C HamanoJul 25, 2018
  8. Beat BolliJul 25, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.