That is an interesting idea to detect the byte order at run-time instead of build-time. However, the build system (autoconf) is already checking it before build-time. Why is if (is_little_endian) { ... } better than #ifndef WORDS_BIGENDIAN ... #endif ? Cheers, Ben On Thu, Nov 18, 2004 at 05:29:47PM +0000, Richard Dobson wrote: > Note that as an alternative to a forest of #ifdefs, it can all be done > programmatically. I got this from the SNDAN sources (I use in pvfileio.c > for reading PVOC_EX files), and don't see why it wouldn't work just as > effectively with a 64bit int: > > static int byte_order() > { > int one = 1; > char* endptr = (char *) &one; > return (*endptr); > } > > e.g: > > int is_little_endian = byte_order(); > > Richard Dobson