Re: [PATCH v6 1/3] Move -D_GNU_SOURCE to CPPFLAGS

Eric Biggers
2020-12-22T00:01:46Z

On Mon, Dec 21, 2020 at 11:24:26PM +0000, Luca Boccassi wrote:
> Ensures it is actually defined before any include is preprocessed.

It was already at the beginning of the .c file, so this isn't a very good
explanation. A better explanation would be "Use _GNU_SOURCE consistently in
every file rather than in just one file. This is needed for the Windows build
in order to consistently get the MinGW version of printf.".

> diff --git a/Makefile b/Makefile
> index bfe83c4..f1ba956 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -47,7 +47,7 @@ override CFLAGS := -Wall -Wundef \
> $(call cc-option,-Wvla) \
> $(CFLAGS)
>
> -override CPPFLAGS := -Iinclude -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)
> +override CPPFLAGS := -Iinclude -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $(CPPFLAGS)
>
> ifneq ($(V),1)
> QUIET_CC = @echo ' CC ' $@;

Can you add -D_GNU_SOURCE to ./scripts/run-sparse.sh too?
Otherwise I get errors when running scripts/run-tests.sh:

[Mon Dec 21 03:52:15 PM PST 2020] Run sparse
./lib/utils.c:71:13: error: undefined identifier 'vasprintf'
./lib/utils.c:78:21: error: undefined identifier 'asprintf'