Martin v. Löwis wrote: ....... >> 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. ...... OK I need to use something a bit more complex then; I figure this should work #if defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) # ifdef __BIG_ENDIAN__ # ifdef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif # define WORDS_BIGENDIAN 1 # else # ifdef __LITTLE_ENDIAN__ # ifdef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif # endif # endif #endif -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list