Created
April 23, 2013 22:00
-
-
Save dennisvennink/5447784 to your computer and use it in GitHub Desktop.
Retrieves the host's byte order. Requires C99.
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
#ifndef ENDIAN_H | |
#define ENDIAN_H | |
#ifndef LITTLE_ENDIAN | |
#define LITTLE_ENDIAN 0 | |
#endif | |
#ifndef BIG_ENDIAN | |
#define BIG_ENDIAN 1 | |
#endif | |
#ifndef BYTE_ORDER | |
#define BYTE_ORDER (*(char *) &(int) {1} == 1 ? LITTLE_ENDIAN : BIG_ENDIAN) | |
#endif | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment