From a95e7b25e6306e8936728118b3cca517828e790a Mon Sep 17 00:00:00 2001 From: Oleh Nykyforchyn Date: Thu, 31 Jul 2025 00:21:32 +0300 Subject: [PATCH] src: move _GNU_SOURCE definition before all includes in files that need vasprintf() Build of input-libinput fails on GCC-11.2 although succeeds on GCC-14.2. Function vasprintf() becomes implicitle declared because its definition in stdio.h is guarded by __GLIBC_USE_LIB_EXT2 which depends on _USE_GNU, which in turn depends on __GNU_SOURCE. __GNU_SOURCE is defined at the beginning of util_string.h before #include , and this file is included by util_strings.c and xf86libinput.c. The latter file includes first a lot of headers in /usr/include and /usr/include/xorg, and finally util_string.h. If some of the previous header files #include , then it is included first without _GNU_SOURCE, and vasprintf() is left undefined, which causes a build error. This patch moves #define _GNU_SOURCE to util_strings.c and xf86libinput.c from util_strings.h, thus making vasprintf() declaration safe and independent of a specific compiler. Signed-off-by: Oleh Nykyforchyn --- src/util-strings.c | 1 + src/util-strings.h | 3 --- src/xf86libinput.c | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util-strings.c b/src/util-strings.c index d0a3fa0..249604b 100644 --- a/src/util-strings.c +++ b/src/util-strings.c @@ -23,6 +23,7 @@ */ #include "config.h" +#define _GNU_SOURCE #include "util-strings.h" diff --git a/src/util-strings.h b/src/util-strings.h index 89d42c0..47306b8 100644 --- a/src/util-strings.h +++ b/src/util-strings.h @@ -24,9 +24,6 @@ #pragma once -#include "config.h" -#define _GNU_SOURCE - #include #include #include diff --git a/src/xf86libinput.c b/src/xf86libinput.c index ad059be..86b9cb9 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -24,6 +24,7 @@ */ #include "config.h" +#define _GNU_SOURCE #include #include