]> git.buserror.net Git - polintos/scott/priv.git/blob - utils/buildendian.c
d9b4e6ed86e4089271cfe1b0c60674eb8847ba51
[polintos/scott/priv.git] / utils / buildendian.c
1 #include <stdio.h>
2 #include <stdint.h>
3
4 int main(void)
5 {
6         union {
7                 uint32_t a;
8                 uint8_t b[4];
9         };
10         
11         a = 0x12345678;
12         
13         if (b[0] == 0x12 && b[1] == 0x34 && b[2] == 0x56 && b[3] == 0x78)
14                 printf("BE");
15         else if (b[3] == 0x12 && b[2] == 0x34 && b[1] == 0x56 && b[0] == 0x78)
16                 printf("LE");
17         else
18                 printf("UNKNOWN");
19         
20         return 0;
21 }