truelight@157: #include truelight@157: truelight@157: // This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN truelight@157: // it does that by putting a 1 and a 0 in an array, and read it out as one truelight@200: // number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN truelight@157: // truelight@157: // After that it outputs the contents of an include files (endian.h) truelight@157: // that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes truelight@157: // care of the real writing to the file. truelight@157: truelight@157: int main () { truelight@157: unsigned char EndianTest[2] = { 1, 0 }; truelight@157: printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n"); truelight@157: if( *(short *) EndianTest == 1 ) truelight@157: printf("#define TTD_LITTLE_ENDIAN\n"); truelight@157: else truelight@157: printf("#define TTD_BIG_ENDIAN\n"); truelight@157: truelight@157: printf("#endif\n"); truelight@157: truelight@157: return 0; truelight@157: }