From 804a401a6e6726de6c24f54c3984358f7c07f14d Mon Sep 17 00:00:00 2001 From: David Hebbeker Date: Thu, 29 Sep 2022 09:20:54 +0200 Subject: [PATCH] Automatically detect native endianness for IAR compiler platform. (#612) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Auto detect native endianness for IAR compiler platform. References: - [IAR C/C++ Development Guide Compiling and Linking for Arm Limited’s **Arm**® Cores](https://wwwfiles.iar.com/arm/webic/doc/ewarm_developmentguide.enu.pdf) - [IAR C/C++ Compiler User Guide for Microchip Technology’s **AVR** Microcontroller Family](https://wwwfiles.iar.com/AVR/webic/doc/EWAVR_CompilerGuide.pdf) * Fix spelling mistake. --- include/etl/endianness.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/etl/endianness.h b/include/etl/endianness.h index 1b758bea..ecb1dde6 100644 --- a/include/etl/endianness.h +++ b/include/etl/endianness.h @@ -42,9 +42,17 @@ SOFTWARE. #endif ///\defgroup endian endian -/// Constants & utilities for endianess +/// Constants & utilities for endianness ///\ingroup utilities +#if !defined(ETL_ENDIAN_NATIVE) && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) + #if __LITTLE_ENDIAN__ == 1 + #define ETL_ENDIAN_NATIVE 0 + #elif __LITTLE_ENDIAN__ == 0 + #define ETL_ENDIAN_NATIVE 1 + #endif +#endif + // Have we not already defined ETL_ENDIAN_NATIVE? #if !defined(ETL_ENDIAN_NATIVE) // Can we use the C++20 definitions?