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