From f4e8084414e07a8e03cb279090bbcf9eea76ed1e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 15 Nov 2023 10:04:57 -0500 Subject: config: New attr_maybe_unused macro --- src/config.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/config.h') diff --git a/src/config.h b/src/config.h index a474fb3..9f95674 100644 --- a/src/config.h +++ b/src/config.h @@ -186,7 +186,7 @@ typedef long double max_align_t; // Wrappers for attributes /** - * Silence compiler warnings about switch/case fall-throughs. + * Silence warnings about switch/case fall-throughs. */ #if __has_c_attribute(fallthrough) # define fallthru [[fallthrough]] @@ -196,6 +196,17 @@ typedef long double max_align_t; # define fallthru ((void)0) #endif +/** + * Silence warnings about unused declarations. + */ +#if __has_c_attribute(maybe_unused) +# define attr_maybe_unused [[maybe_unused]] +#elif __has_attribute(unused) +# define attr_maybe_unused __attribute__((unused)) +#else +# define attr_maybe_unused +#endif + /** * Warn if a value is unused. */ -- cgit v1.2.3