Determining endianness

The file <gulliver.h> contains macros to help resolve endian issues.

The first thing you may need to know is the target system's endianness, which you can find out via the following macros:

__LITTLEENDIAN__
defined if little-endian
__BIGENDIAN__
defined if big-endian

A common coding style in the header files (e.g., <gulliver.h>) is to check which macro is defined and to report an error if none is defined:

#if defined(__LITTLEENDIAN__)
// do whatever for little-endian
#elif defined(__BIGENDIAN__)
// do whatever for big-endian
#else
#error ENDIAN Not defined for system
#endif

The #error statement will cause the compiler to generate an error and abort the compilation.