Here is a good example of what is required properly for different architectures / libc implementations / compiler suites:

https://svn.apache.org/repos/asf/incubator/ooo/trunk/main/sal/inc/osl/endian.h