Add support to cross-compile with clang (#389)

Clang does not define __WCHAR_MIN__ however, limits.h relies on it.
By using the __AVR__ macro we can define __WCHAR_MIN__ only when
cross-compiling with clang.
This commit is contained in:
T 2021-06-18 07:52:34 -04:00 committed by John Wellbelove
parent 2e0c2a4099
commit 32d80e91e7
2 changed files with 8 additions and 0 deletions

View File

@ -332,6 +332,11 @@ namespace etl
static ETL_CONSTANT bool is_signed = etl::is_signed<wchar_t>::value;
static ETL_CONSTANT bool is_modulo = etl::is_unsigned<wchar_t>::value;
#if defined(ETL_COMPILER_CLANG) && defined(CROSS_COMPILING_TO_AVR)
#undef WCHAR_MIN
#define WCHAR_MIN (-WCHAR_MAX - 1)
#endif
static ETL_CONSTEXPR wchar_t min() { return WCHAR_MIN; }
static ETL_CONSTEXPR wchar_t max() { return WCHAR_MAX; }
static ETL_CONSTEXPR wchar_t lowest() { return WCHAR_MIN; }

View File

@ -75,6 +75,9 @@ SOFTWARE.
#if defined(__clang__) || defined(__llvm__)
#define ETL_COMPILER_CLANG
#define ETL_COMPILER_TYPE_DETECTED
#if __AVR__ == 1
#define CROSS_COMPILING_TO_AVR
#endif
#endif
#endif