diff --git a/include/toolchain.h b/include/toolchain.h index 88cedb0fb3b..adc8c2c1101 100644 --- a/include/toolchain.h +++ b/include/toolchain.h @@ -41,4 +41,18 @@ #include #endif +/* + * Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined, + * as these are often used without checking for definition and doing so can + * cause unexpected behaviours. + */ +#ifndef _LINKER +#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \ + !defined(__ORDER_LITTLE_ENDIAN__) + +#error "__BYTE_ORDER__ is not defined" + +#endif +#endif /* !_LINKER */ + #endif /* ZEPHYR_INCLUDE_TOOLCHAIN_H_ */