Edited: I see that cmake has a TestBigEndian.cmake script, but it compiles and checks to check if the system is Big Endian or not, which you don't want to do.
You can check the system entity in your own program using such a function.
bool isLittleEndian() { short int number = 0x1; char *numPtr = (char*)&number; return (numPtr[0] == 1); }
In principle, create an integer and read its first byte (low byte). If this byte is 1, the system is of little importance, otherwise it is a big end.
However, this does not allow you to determine, until the end, before the time runs out.
If you want the compilation time to be determined by the system, I don’t see a big alternative, except for “creating a test program and then compiling my real program” a la cmake or performing exhaustive checks for certain macros defined by compilers, for example __BIG_ENDIAN__ on GCC 4. x.
UPDATED As an example, you can also take a look at Boost own endian.hpp . http://www.boost.org/doc/libs/1_43_0/boost/detail/endian.hpp
birryree
source share