toolchain: Add global check for endianness preprocessor definitions.
This commit adds a global check for __BYTE_ORDER__, __ORDER_LITTLE_ENDIAN__ and __ORDER_BIG_ENDIAN__ preprocessor definitions that are used throughout the Zephyr codebase. These preprocessor definitions being not defined can easily go unnoticed and cause unexpected behaviours, as detailed in PR #18922. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
parent
5a53e21966
commit
91e75075ae
1 changed files with 14 additions and 0 deletions
|
@ -41,4 +41,18 @@
|
|||
#include <toolchain/other.h>
|
||||
#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_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue