00001 #include <stdio.h> 00002 00003 enum { LITTLE_ENDIAN, BIG_ENDIAN }; 00004 00005 int get_endianess() { 00006 long i = 1; 00007 const char *p = (const char *) &i; 00008 if (p[0] == 1) return LITTLE_ENDIAN; // LSB correspond à 1 00009 return BIG_ENDIAN; 00010 } 00011 00012 int main() 00013 { 00014 int n = get_endianess(); 00015 printf("%s\n", (get_endianess() == LITTLE_ENDIAN)?"LITTLE_ENDIAN":"BIG_ENDIAN"); 00016 return 0; 00017 }