Skip to content

Commit fd4c1e7

Browse files
committed
Support clang compiler
1 parent ae364b1 commit fd4c1e7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/common/tusb_compiler.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@
123123
//--------------------------------------------------------------------+
124124

125125
// TODO refactor since __attribute__ is supported across many compiler
126-
#if defined(__GNUC__)
126+
#if defined(__GNUC__) || defined (__clang__)
127127
#define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
128128
#define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
129129
#define TU_ATTR_PACKED __attribute__ ((packed))
130-
#define TU_ATTR_WEAK __attribute__ ((weak))
130+
#if defined(__clang__)
131+
#define TU_ATTR_WEAK __attribute__ ((weak_import))
132+
#else
133+
#define TU_ATTR_WEAK __attribute__ ((weak))
134+
#endif
131135
#ifndef TU_ATTR_ALWAYS_INLINE // allow to override for debug
132136
#define TU_ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
133137
#endif

0 commit comments

Comments
 (0)