From 9e2ac55dbc81288bd174b91c781ec70a7f07b739 Mon Sep 17 00:00:00 2001 From: Mike Crowe Date: Sun, 30 Aug 2020 11:24:38 +0100 Subject: [PATCH] libratbag-private.h: Ensure that _GNU_SOURCE is defined early enough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling on Ubuntu 20.04 with GCC 9.3.0 and glibc 2.31, I get: In file included from ../src/libratbag-private.h:32, from ../src/driver-sinowealth.c:24: ../src/libratbag-util.h: In function ‘asprintf_safe’: ../src/libratbag-util.h:154:7: warning: implicit declaration of function ‘vasprintf’; did you mean ‘vsprintf’? [-Wimplicit-function-declaration] 154 | rc = vasprintf(&result, fmt, args); | ^~~~~~~~~ | vsprintf This appears to be because is being included by another header before config.h has been included. If _GNU_SOURCE has not been defined at that point, then the other macros that control whether vasprintf is declared are not set correctly. Include config.h right at the top of libratbag-private.h to ensure that _GNU_SOURCE is defined before any system headers are included to avoid this problem. --- src/libratbag-private.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libratbag-private.h b/src/libratbag-private.h index 3d8b6e77..d7e964f1 100644 --- a/src/libratbag-private.h +++ b/src/libratbag-private.h @@ -23,6 +23,7 @@ #pragma once +#include "config.h" #include #include #include