Message ID | 20201221232428.298710-1-bluca@debian.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v6,1/3] Move -D_GNU_SOURCE to CPPFLAGS | expand |
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'
On Tue, 22 Dec 2020 at 00:00, Eric Biggers <ebiggers@kernel.org> wrote: > > 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.". Ok, copied verbatim in v7. > > 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' Sure, done in v7. Kind regards, Luca Boccassi
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 ' $@; diff --git a/lib/utils.c b/lib/utils.c index 8b5d6cb..13e3b35 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -9,8 +9,6 @@ * https://opensource.org/licenses/MIT. */ -#define _GNU_SOURCE /* for asprintf() and strerror_r() */ - #include "lib_private.h" #include <stdio.h>
Ensures it is actually defined before any include is preprocessed. Signed-off-by: Luca Boccassi <bluca@debian.org> --- v6: split from mingw patch Makefile | 2 +- lib/utils.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)