I surprised no-one has mentioned the macros which the pre-processor defines by default. While these will vary depending on your platform; they are much cleaner than having to write your own endian-check.
For example; if we look at the built-in macros which GCC defines (on an X86-64 machine):
:| gcc -dM -E -x c - |grep -i endian
#define __LITTLE_ENDIAN__ 1
On a PPC machine I get:
:| gcc -dM -E -x c - |grep -i endian
#define __BIG_ENDIAN__ 1
#define _BIG_ENDIAN 1
(The :| gcc -dM -E -x c -
magic prints out all built-in macros).