From 749f2227c67b5b07fe9c6633b0b8767de511a8b2 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Wed, 4 Oct 2023 15:38:58 +0100 Subject: [PATCH] Get MBEDTLS_MAYBE_UNUSED to cover more compilers Signed-off-by: Dave Rodgman --- library/common.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/library/common.h b/library/common.h index 910106bde..436e35a91 100644 --- a/library/common.h +++ b/library/common.h @@ -335,15 +335,23 @@ static inline void mbedtls_xor_no_simd(unsigned char *r, #endif /* Suppress compiler warnings for unused functions and variables. */ -#if defined(__GNUC__) -#define MBEDTLS_MAYBE_UNUSED __attribute__((unused)) -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__VER__) -#if (__VER__ >= 8000000) +#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__GNUC__) #define MBEDTLS_MAYBE_UNUSED __attribute__((unused)) #endif -#elif defined(_MSC_VER) +#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__IAR_SYSTEMS_ICC__) && defined(__VER__) +#if (__VER__ >= 8010000) // IAR 8.1 or later +#define MBEDTLS_MAYBE_UNUSED __attribute__((unused)) +#endif +#endif +#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(_MSC_VER) #define MBEDTLS_MAYBE_UNUSED __pragma(warning(suppress:4189)) -#else +#endif +#if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__has_attribute) +#if __has_attribute(unused) +#define MBEDTLS_MAYBE_UNUSED __attribute__((unused)) +#endif +#endif +#if !defined(MBEDTLS_MAYBE_UNUSED) #define MBEDTLS_MAYBE_UNUSED #endif