diff --git a/Makefile.defs b/Makefile.defs index 88b746e5e..be504caa9 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -51,8 +51,6 @@ DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-s # Some more warnings we need first to eliminate, so temporarely tolerated: DEFCFLAGS += -Wcast-align -Wno-error=cast-align DEFCFLAGS += -Wswitch-enum -Wno-error=switch-enum -# Termux on-device __BYTE_ORDER and __LITTLE_ENDIAN undef in src/proxendian.h, see #730 -DEFCFLAGS += -Wno-error=undef ifeq ($(platform),Darwin) # their readline has strict-prototype issues diff --git a/client/src/proxendian.h b/client/src/proxendian.h index fde5126b1..3a025b7ac 100644 --- a/client/src/proxendian.h +++ b/client/src/proxendian.h @@ -16,17 +16,22 @@ #ifdef _WIN32 # define HOST_LITTLE_ENDIAN #else -# include -# ifndef BYTE_ORDER -# define BYTE_ORDER __BYTE_ORDER -# define LITTLE_ENDIAN __LITTLE_ENDIAN -# define BIG_ENDIAN __BIG_ENDIAN -# endif -# if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) -# error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN -# endif -# if BYTE_ORDER == LITTLE_ENDIAN -# define HOST_LITTLE_ENDIAN +// Only some OSes include endian.h from sys/types.h, not Termux, so let's include endian.h directly +# include +# if !defined(BYTE_ORDER) +# if !defined(__BYTE_ORDER) || (__BYTE_ORDER != __LITTLE_ENDIAN && __BYTE_ORDER != __BIG_ENDIAN) +# error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define HOST_LITTLE_ENDIAN +# endif +# else +# if BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN +# error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN +# endif +# if BYTE_ORDER == LITTLE_ENDIAN +# define HOST_LITTLE_ENDIAN +# endif # endif #endif