From 1d711a2ced0d087ad1a7da23499c7ded4b4903db Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 2 Nov 2024 23:12:40 +0100 Subject: [PATCH] =?utf8?q?include:=20Refactor=20=C2=ABunused=C2=BB=20attri?= =?utf8?q?bute=20into=20new=20LIBBSD=5FUNUSED=20macro?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This make it possible to declare function arguments in headers as potentially unused, so that they do not emit warnings. We will use this instead of the BSD __unused, which we cannot currently enable on GNU systems due to Linux and glibc having conflicting symbols. --- include/bsd/sys/cdefs.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h index d2627c4..3df88b5 100644 --- a/include/bsd/sys/cdefs.h +++ b/include/bsd/sys/cdefs.h @@ -99,6 +99,12 @@ #define LIBBSD_GCC_VERSION 0 #endif +#if LIBBSD_GCC_VERSION >= 0x0300 || __has_attribute(__unused__) +# define LIBBSD_UNUSED __attribute__((__unused__)) +#else +# define LIBBSD_UNUSED +#endif + #if LIBBSD_GCC_VERSION >= 0x0405 || __has_attribute(__deprecated__) #define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x))) #elif LIBBSD_GCC_VERSION >= 0x0301 @@ -150,11 +156,7 @@ * Disable for now. */ #if 0 #ifndef __unused -# if LIBBSD_GCC_VERSION >= 0x0300 -# define __unused __attribute__((__unused__)) -# else -# define __unused -# endif +# define __unused LIBBSD_UNUSED #endif #endif -- 2.47.2