From f842868dd9dfe3105d0357a66246ec1ca0d10de9 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 24 Oct 2023 14:18:38 +0100 Subject: [PATCH 1/2] Fix MBEDTLS_MAYBE_UNUSED for IAR Signed-off-by: Dave Rodgman --- library/common.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/common.h b/library/common.h index 570b97eca..73b3d6127 100644 --- a/library/common.h +++ b/library/common.h @@ -344,8 +344,11 @@ static inline void mbedtls_xor_no_simd(unsigned char *r, # define MBEDTLS_MAYBE_UNUSED __attribute__((unused)) #endif #if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__IAR_SYSTEMS_ICC__) && defined(__VER__) +/* IAR does support __attribute__((unused)), but only if the -e flag (extended language support) + * is given; the pragma always works. + * Unfortunately the pragma affects the rest of the file where it is used, but this is harmless. */ # if (__VER__ >= 8010000) // IAR 8.1 or later -# define MBEDTLS_MAYBE_UNUSED __attribute__((unused)) +# define MBEDTLS_MAYBE_UNUSED _Pragma("diag_suppress=Pe177") # endif #endif #if !defined(MBEDTLS_MAYBE_UNUSED) && defined(_MSC_VER) From d1c4fb07eead59921b25cfa21dc606788c57539f Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Wed, 25 Oct 2023 15:07:35 +0100 Subject: [PATCH 2/2] Support older IAR versions Signed-off-by: Dave Rodgman --- library/common.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/common.h b/library/common.h index 73b3d6127..87fae171c 100644 --- a/library/common.h +++ b/library/common.h @@ -346,8 +346,11 @@ static inline void mbedtls_xor_no_simd(unsigned char *r, #if !defined(MBEDTLS_MAYBE_UNUSED) && defined(__IAR_SYSTEMS_ICC__) && defined(__VER__) /* IAR does support __attribute__((unused)), but only if the -e flag (extended language support) * is given; the pragma always works. - * Unfortunately the pragma affects the rest of the file where it is used, but this is harmless. */ -# if (__VER__ >= 8010000) // IAR 8.1 or later + * Unfortunately the pragma affects the rest of the file where it is used, but this is harmless. + * Check for version 5.2 or later - this pragma may be supported by earlier versions, but I wasn't + * able to find documentation). + */ +# if (__VER__ >= 5020000) # define MBEDTLS_MAYBE_UNUSED _Pragma("diag_suppress=Pe177") # endif #endif