1: #include <iostream>
2: #include "../lib/unpsunyj.h"
3:
4: int main(int argc, char **argv)
5: {
6: union {
7: short s;
8: char c[sizeof(short)];
9: } un;
10:
11: un.s = 0x0103;
12: std::cout << "un.s =: " << un.s << std::endl;
13: printf("%s: ", CPU_VENDOR_OS);
14: if (sizeof(short) == 2)
15: {
16: if (un.c[0] == 1 && un.c[1] == 3)
17: printf("big-endian ");
18: else if (un.c[0] == 3 && un.c[1] == 1)
19: printf("little-endian ");
20: else
21: printf("unknown ");
22: }
23: else
24: printf("sizeof(short) = %d ", static_cast<int>(sizeof(short)));
25:
26: return 0;
27: }
28: