1 #include <simgear/compiler.h>
4 #include "lowlevel.hxx"
7 static const int sgEndianTest = 1;
8 #define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
9 #define sgIsBigEndian (*((char *) &sgEndianTest ) == 0)
16 cout << "This machine is ";
17 if ( sgIsLittleEndian ) {
22 cout << "endian" << endl;
24 cout << "sizeof(short) = " << sizeof(short) << endl;
27 cout << "short s = " << s << endl;
28 sgEndianSwap((uint16_t *)&s);
29 cout << "short s = " << s << endl;
30 sgEndianSwap((uint16_t *)&s);
31 cout << "short s = " << s << endl;
34 cout << "int i = " << i << endl;
35 sgEndianSwap((uint32_t *)&i);
36 cout << "int i = " << i << endl;
37 sgEndianSwap((uint32_t *)&i);
38 cout << "int i = " << i << endl;
40 double x = 1111111111;
41 cout << "double x = " << x << endl;
42 sgEndianSwap((uint64_t *)&x);
43 cout << "double x = " << x << endl;
44 sgEndianSwap((uint64_t *)&x);
45 cout << "double x = " << x << endl;