diff --git a/sc2/src/endian_uqm.h b/sc2/src/endian_uqm.h index 5f3910e3e..759008bc7 100644 --- a/sc2/src/endian_uqm.h +++ b/sc2/src/endian_uqm.h @@ -25,6 +25,23 @@ #include "config.h" #include "types.h" +#if defined (__APPLE__) && defined (__GNUC__) +// When using the MacOS gcc compiler to build universal binaries, +// each file will be compiled once for each platform. +// This means that checking endianness beforehand from build.sh will not do, +// but fortunately, gcc defines __BIG_ENDIAN__ or __LITTLE_ENDIAN__ on +// this platform. +# if defined(__BIG_ENDIAN__) +# undef WORDS_BIGENDIAN +# define WORDS_BIGENDIAN +# elif defined(__LITTLE_ENDIAN__) +# undef WORDS_BIGENDIAN +# else + // Neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__ is defined. + // Fallback to using the build.sh defined value. +# endif +#endif /* __APPLE__ */ + #if defined(_MSC_VER) || defined(__BORLANDC__) || \ defined(__DMC__) || defined(__SC__) || \ defined(__WATCOMC__) || defined(__LCC__) diff --git a/sc2/src/sc2code/libs/network/bytesex.h b/sc2/src/sc2code/libs/network/bytesex.h index 34a678260..99b644db7 100644 --- a/sc2/src/sc2code/libs/network/bytesex.h +++ b/sc2/src/sc2code/libs/network/bytesex.h @@ -27,7 +27,7 @@ #include "port.h" // for inline -#include "config.h" +#include "endian_uqm.h" // for WORDS_BIGENDIAN #include "types.h" diff --git a/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.h b/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.h index 01a212659..1635eb276 100644 --- a/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.h +++ b/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.h @@ -23,6 +23,7 @@ #include "config.h" #include "libs/sound/sound.h" #include "options.h" +#include "endian_uqm.h" #if defined (__APPLE__) # include