25
Oct
Finding endianness
Related Blog Items
- Binary Streams Utility Classes
- Little, Big endianess explained
- Little, big endianess explained -- part2
- Detecting a loop in single linked list
- Structure padding explained
to know about endianness, please refer to my earlier posts…
Little, Big endianess explained
Little, big endianess explained - part2
here is the snippet for finding endianness…
//returns zero for little endian //returns 1 for big endian //otherwise some error occured int find_endianness() { int x = 0x01 ; if (* (char *) &x == 1) { //little endian return 0; } else if (*((char *)&x+sizeof(int)-1)==1) { //big endian return 1; } else { //could not find what we have written in that byte return -1; } return 0; }
Popularity: 20%
You need to log on to convert this article into PDF
Related Blog Items - Binary Streams Utility Classes
- Little, Big endianess explained
- Little, big endianess explained -- part2
- Detecting a loop in single linked list
- Structure padding explained
Related Blog Items
- Binary Streams Utility Classes
- Little, Big endianess explained
- Little, big endianess explained -- part2
- Detecting a loop in single linked list
- Structure padding explained
is there any way of knowing endianness at compile time?
December 19th, 2007 at 8:53 pm
ok, http://www.openasthra.com/embedded-systems-programming/little-big-endianess-explained/ post answered my question, thanks.
December 19th, 2007 at 8:54 pm