I'm trying to write a program that detects endianess and returns the endianess type (1 for little, 0 for big) or -1 if none of them. but I encountered this problem: when I try to mask unsigned long word with an unsigned char, and then I try to compare this char to is ASCII value the code inside the if condition becomes unreachable appearrantly...
int is_little_endian() {
unsigned long word = 0x6600000000000088;
unsigned char maskedWord = word;
if (maskedWord == 'X') {
return 0;
} else if (maskedWord == 'B') {
return 1;
} else return -1;
}
Thanks!