Hi! So, assuming I'm on glibc with GCC 4.5 on powerpc64-linux.
On Tue, Mar 24, 2020 at 09:49:42AM +0100, Martin Liška wrote: > +/* Detect endianess based on __BYTE_ORDER__ macro. */ > +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ > + defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_PDP_ENDIAN__) > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +#define PLUGIN_LITTLE_ENDIAN 1 > +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ > +#define PLUGIN_BIG_ENDIAN 1 > +#elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ > +#define PLUGIN_PDP_ENDIAN 1 > +#endif > +#else > +/* Older GCC releases (<4.6.0) can make detection from glibc macros. */ > +#if defined(__GLIBC__) || defined(__GNU_LIBRARY__) || defined(__ANDROID__) > +#include <endian.h> > +#if __BYTE_ORDER == __LITTLE_ENDIAN > +#define PLUGIN_LITTLE_ENDIAN 1 > +#elif __BYTE_ORDER == __BIG_ENDIAN > +#define PLUGIN_BIG_ENDIAN 1 > +#endif This will definePLUGIN_BIG_ENDIAN. > +#endif > +/* Include all necessary header files based on target. */ > +#if defined(__SVR4) && defined(__sun) > +#include <sys/byteorder.h> > +#endif > +#if defined(__FreeBSD__) || defined(__NetBSD__) || \ > + defined(__DragonFly__) || defined(__minix) > +#include <sys/endian.h> > +#endif > +#if defined(__OpenBSD__) > +#include <machine/endian.h> > +#endif The above headers will not be included. > +/* Detect endianess based on _BYTE_ORDER. */ > +#if _BYTE_ORDER == _LITTLE_ENDIAN So most likely _BYTE_ORDER and _LITTLE_ENDIAN macros will not be defined. Which means this will be handled as #if 0 == 0 and override the > +#define PLUGIN_LITTLE_ENDIAN 1 will define also PLUGIN_LITTLE_ENDIAN. > +#elif _BYTE_ORDER == _BIG_ENDIAN > +#define PLUGIN_BIG_ENDIAN 1 > +#endif > +/* Detect based on _WIN32. */ > +#if defined(_WIN32) > +#define PLUGIN_LITTLE_ENDIAN 1 > +#endif > +/* Fallback to __BIG_ENDIAN__ and __LITTLE_ENDIAN__ */ > +#ifdef __LITTLE_ENDIAN__ > +#define PLUGIN_LITTLE_ENDIAN 1 > +#endif > +#ifdef __BIG_ENDIAN__ > +#define PLUGIN_BIG_ENDIAN 1 > +#endif > +#endif and the above isn't really a fallback, because it isn't guarded with PLUGIN_*_ENDIAN not being defined yet. Jakub