From fd4c1e79164525fc5a55c4c9e93f1cf5a612e66c Mon Sep 17 00:00:00 2001 From: Ryzee119 Date: Sat, 6 Jan 2024 16:45:49 +1030 Subject: [PATCH] Support clang compiler --- src/common/tusb_compiler.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h index 6f07bdd536..dde70ce076 100644 --- a/src/common/tusb_compiler.h +++ b/src/common/tusb_compiler.h @@ -123,11 +123,15 @@ //--------------------------------------------------------------------+ // TODO refactor since __attribute__ is supported across many compiler -#if defined(__GNUC__) +#if defined(__GNUC__) || defined (__clang__) #define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes))) #define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name))) #define TU_ATTR_PACKED __attribute__ ((packed)) - #define TU_ATTR_WEAK __attribute__ ((weak)) + #if defined(__clang__) + #define TU_ATTR_WEAK __attribute__ ((weak_import)) + #else + #define TU_ATTR_WEAK __attribute__ ((weak)) + #endif #ifndef TU_ATTR_ALWAYS_INLINE // allow to override for debug #define TU_ATTR_ALWAYS_INLINE __attribute__ ((always_inline)) #endif