Created
April 29, 2015 20:15
-
-
Save mattypiper/0793a2bfa10c00707bcb to your computer and use it in GitHub Desktop.
Runtime Endian Detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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