]> git.mxchange.org Git - simgear.git/blob - simgear/io/lowtest.cxx
Merge branch 'timoore/effects-anim-rebase' into next
[simgear.git] / simgear / io / lowtest.cxx
1 #include <simgear/compiler.h>
2
3 #include <iostream>
4 #include "lowlevel.hxx"
5
6
7 static const int sgEndianTest = 1;
8 #define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
9 #define sgIsBigEndian    (*((char *) &sgEndianTest ) == 0)
10
11 using std::cout;
12 using std::endl;
13
14
15 int main() {
16     cout << "This machine is ";
17     if ( sgIsLittleEndian ) {
18         cout << "little ";
19     } else {
20         cout << "big ";
21     }
22     cout << "endian" << endl;
23
24     cout << "sizeof(short) = " << sizeof(short) << endl;
25
26     short s = 1111;
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;
32
33     int i = 1111111;
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;
39
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;
46 }