]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
include: Refactor «unused» attribute into new LIBBSD_UNUSED macro
authorGuillem Jover <guillem@hadrons.org>
Sat, 2 Nov 2024 22:12:40 +0000 (23:12 +0100)
committerGuillem Jover <guillem@hadrons.org>
Sat, 26 Jul 2025 10:25:40 +0000 (12:25 +0200)
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

index d2627c463920fbbad5be393fb6c807fb12823578..3df88b5c1343ecfdb7e30769397f6c58ce93dbc3 100644 (file)
 #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
  * 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