1#include <stdio.h> 2 3int 4main() 5{ 6 7 unsigned int u1; 8 char *c; 9 double d1; 10 float *f1; 11 12 c = (char *) &u1; 13 u1 = 0x0F; 14 if (c[0] == 0x0F) 15 puts("#define HOST_LITTLE_ENDIAN\n"); 16 else 17 puts("#define HOST_BIG_ENDIAN\n"); 18 19 d1 = 1.0; 20 f1 = (float *) &d1; 21 if (*((int *) f1) != 0x3ff00000) 22 puts("#define HOST_LITTLE_ENDIAN_FLOAT\n"); 23 else 24 puts("#define HOST_BIG_ENDIAN_FLOAT\n"); 25 return 0; 26} 27