distutils & OS X universal binaries

"Martin v. Löwis" martin at v.loewis.de
Sat Dec 8 12:05:02 EST 2007


> #ifdef __BIG_ENDIAN__
> #define WORDS_BIGENDIAN 1
> #else
> #ifndef __LITTLE_ENDIAN__
> #undef WORDS_BIGENDIAN
> #endif
> #endif
> 
> 
> I'm puzzled why WORDS_BIGENDIAN is undefined if both __BIG_ENDIAN__ and
> __LITTLE_ENDIAN__ are undefined. Surely in that case WORDS_BIGENDIAN
> should be left alone (if it is already defined). If there's a compiler
> for a bigendian architecture which doesn't define the gcc macros the we
> seem to get the wrong result.

No. pyconfig.h.in gets processed by configure into pyconfig.h; configure
replaces all #undef lines with appropriate #define lines if the macro
got define in configure. The autoconf macro AC_C_BIGENDIAN performs
a configure-time check. So

- if the compiler either defines __BIG_ENDIAN__ or __LITTLE_ENDIAN__,
  that is taken for granted.
- otherwise, the configure-time value is used

On your normal big-endian compiler (e.g. SPARC), it's the
configure-time value that makes WORDS_BIGENDIAN defined.

HTH,
Martin



More information about the Python-list mailing list