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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 23, 2018, 18:51 UTC
Message-ID
<xmqqzhyh6b05.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<87wotobclv.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 7 quoted lines
>> +CFLAGS += -pedantic
>> +# don't warn for each N_ use
>> +CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
>> +endif
>
> ...and set this to "no" not "0" since we document that that's the way to
> toggle it off in the Makefile, i.e. let's be consistent.

The Make variable USE_PARENS_AROUND_GETTEXT_N is described as taking "yes" or "no".

    # Define USE_PARENS_AROUND_GETTEXT_N to "yes" if your compiler happily
    # compiles the following initialization:
    #
    #   static const char s[] = ("FOO");
    #
    # and define it to "no" if you need to remove the parentheses () around the
    # constant.  The default is "auto", which means to use parentheses if your
    # compiler is detected to support it.
But the knob on the CFLAGS set by these variables take 1 or 0
    ifeq (yes,$(USE_PARENS_AROUND_GETTEXT_N))
            BASIC_CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=1
    else
    ifeq (no,$(USE_PARENS_AROUND_GETTEXT_N))
            BASIC_CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
    endif
    endif
And the code that uses the CFLAGS knob 
    /* Mark msgid for translation but do not translate it. */
    #if !USE_PARENS_AROUND_GETTEXT_N
    #define N_(msgid) msgid
    #else
    ...
    #define N_(msgid) (msgid)
    #endif

pays attention to the truth/false in usual C preprocessor sense. Your "no" happens to serve as 0 just like "yes" would.

So I think you suggestion is a bad one that makes a misleading result.

[Footnote]
*1* The following shows all "not X" except for "not one".
#include <stdio.h>

#define ZERO 0 #define ONE 1 #define YES yes #define NO no #undef UNDEF

const char *msgs[] = {
#if !ZERO
	"not zero",
#endif
#if !ONE
	"not one",
#endif
#if !YES
	"not yes",
#endif
#if !NO
	"not no",
#endif
#if !UNDEF
	"not undef",
#endif
	NULL
};
int main(int ac, char **av)
{
	const char **cp = msgs;
	while (*cp) {
		printf("%s\n", *cp);
		cp++;
	}
	return 0;
}
Previous: Ævar Arnfjörð Bjarmason
Message 3 of 3 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. Ævar Arnfjörð BjarmasonJul 21, 2018
  3. Junio C HamanoJul 23, 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.