Skip to content

Instantly share code, notes, and snippets.

@mattypiper
Created April 29, 2015 20:15
Runtime Endian Detection
uint16_T one = 1U;
enum {
LittleEndian,
BigEndian
} machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
switch (machByteOrder) {
case LittleEndian:
// code here
break;
case BigEndian:
// code here
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment