diff --git a/Makefile b/Makefile index f4a7998..8e365b9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ CC := cc -CPPFLAGS := -Iinclude -MMD -MP +# Feature test macros belong to the build, not to individual files: declaring +# them per-source drifted into four different combinations across nine files. +# _POSIX_C_SOURCE covers getline and realpath(path, NULL); _DEFAULT_SOURCE adds +# dirent.d_type, which walk uses as a fast path. SPEC.md section 19 targets +# POSIX, so nothing here asks for _GNU_SOURCE. +FEATURES := -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE + +CPPFLAGS := -Iinclude -MMD -MP $(FEATURES) # -O2 is not only about speed: without optimisation GCC skips the flow # analysis that most of these warnings are derived from. diff --git a/src/create.c b/src/create.c index 881a143..1826d2d 100644 --- a/src/create.c +++ b/src/create.c @@ -1,6 +1,3 @@ -#define _POSIX_C_SOURCE 200809L -#define _DEFAULT_SOURCE -#define _XOPEN_SOURCE 700 #include "create.h" #include "types.h" #include "utility.h" diff --git a/src/diff.c b/src/diff.c index e27ab26..d0aee5c 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "diff.h" #include "types.h" #include "utility.h" diff --git a/src/list.c b/src/list.c index 17aab9a..28be379 100644 --- a/src/list.c +++ b/src/list.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "list.h" #include "types.h" #include "utility.h" diff --git a/src/scan.c b/src/scan.c index 10c60b0..a1fc82d 100644 --- a/src/scan.c +++ b/src/scan.c @@ -1,4 +1,3 @@ -#define _DEFAULT_SOURCE #include "scan.h" #include "utility.h" #include "walk.h" diff --git a/src/types.c b/src/types.c index ab7686a..226244c 100644 --- a/src/types.c +++ b/src/types.c @@ -1,6 +1,3 @@ -#define _POSIX_C_SOURCE 200809L -#define _DEFAULT_SOURCE -#define _XOPEN_SOURCE 700 #include "hash.h" #include "types.h" #include diff --git a/src/utility.c b/src/utility.c index d738778..4c1397d 100644 --- a/src/utility.c +++ b/src/utility.c @@ -1,4 +1,3 @@ -#define _XOPEN_SOURCE 700 #include "utility.h" #include #include diff --git a/src/walk.c b/src/walk.c index 49ab571..9155fd2 100644 --- a/src/walk.c +++ b/src/walk.c @@ -1,4 +1,3 @@ -#define _GNU_SOURCE #include "utility.h" #include "walk.h" #include