mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'fix/flag_attr_static' into 'master'
esp_attr: Fix multiple definition linker error for operators for C++ build including FLAG_ATTR'ed enum. Closes IDF-1091 See merge request espressif/esp-idf!6469
This commit is contained in:
commit
d90dd48e48
@ -80,18 +80,19 @@
|
||||
// Format: FLAG_ATTR(flag_enum_t)
|
||||
#ifdef __cplusplus
|
||||
|
||||
// Inline is required here to avoid multiple definition error in linker
|
||||
#define FLAG_ATTR_IMPL(TYPE, INT_TYPE) \
|
||||
constexpr TYPE operator~ (TYPE a) { return (TYPE)~(INT_TYPE)a; } \
|
||||
constexpr TYPE operator| (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a | (INT_TYPE)b); } \
|
||||
constexpr TYPE operator& (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a & (INT_TYPE)b); } \
|
||||
constexpr TYPE operator^ (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a ^ (INT_TYPE)b); } \
|
||||
constexpr TYPE operator>> (TYPE a, int b) { return (TYPE)((INT_TYPE)a >> b); } \
|
||||
constexpr TYPE operator<< (TYPE a, int b) { return (TYPE)((INT_TYPE)a << b); } \
|
||||
TYPE& operator|=(TYPE& a, TYPE b) { a = a | b; return a; } \
|
||||
TYPE& operator&=(TYPE& a, TYPE b) { a = a & b; return a; } \
|
||||
TYPE& operator^=(TYPE& a, TYPE b) { a = a ^ b; return a; } \
|
||||
TYPE& operator>>=(TYPE& a, int b) { a >>= b; return a; } \
|
||||
TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; }
|
||||
FORCE_INLINE_ATTR constexpr TYPE operator~ (TYPE a) { return (TYPE)~(INT_TYPE)a; } \
|
||||
FORCE_INLINE_ATTR constexpr TYPE operator| (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a | (INT_TYPE)b); } \
|
||||
FORCE_INLINE_ATTR constexpr TYPE operator& (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a & (INT_TYPE)b); } \
|
||||
FORCE_INLINE_ATTR constexpr TYPE operator^ (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a ^ (INT_TYPE)b); } \
|
||||
FORCE_INLINE_ATTR constexpr TYPE operator>> (TYPE a, int b) { return (TYPE)((INT_TYPE)a >> b); } \
|
||||
FORCE_INLINE_ATTR constexpr TYPE operator<< (TYPE a, int b) { return (TYPE)((INT_TYPE)a << b); } \
|
||||
FORCE_INLINE_ATTR TYPE& operator|=(TYPE& a, TYPE b) { a = a | b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator&=(TYPE& a, TYPE b) { a = a & b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator^=(TYPE& a, TYPE b) { a = a ^ b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator>>=(TYPE& a, int b) { a >>= b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; }
|
||||
|
||||
#define FLAG_ATTR_U32(TYPE) FLAG_ATTR_IMPL(TYPE, uint32_t)
|
||||
#define FLAG_ATTR FLAG_ATTR_U32
|
||||
|
Loading…
x
Reference in New Issue
Block a user