]> git.mxchange.org Git - simgear.git/blob - simgear/io/lowtest.cxx
Attempt to resolve ambiguity between #include <config.h> for simgear vs.
[simgear.git] / simgear / io / lowtest.cxx
1 #include <simgear/compiler.h>
2
3 #include STL_IOSTREAM
4 #include "lowlevel.hxx"
5
6 static const int sgEndianTest = 1;
7 #define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
8 #define sgIsBigEndian    (*((char *) &sgEndianTest ) == 0)
9
10
11 int main() {
12     cout << "This machine is ";
13     if ( sgIsLittleEndian ) {
14         cout << "little ";
15     } else {
16         cout << "big ";
17     }
18     cout << "endian" << endl;
19
20     short s = 1111;
21     cout << "short s = " << s << endl;
22     sgEndianSwap((unsigned short *)&s);
23     cout << "short s = " << s << endl;
24     sgEndianSwap((unsigned short *)&s);
25     cout << "short s = " << s << endl;
26
27     int i = 1111111;
28     cout << "int i = " << i << endl;
29     sgEndianSwap((unsigned int *)&i);
30     cout << "int i = " << i << endl;
31     sgEndianSwap((unsigned int *)&i);
32     cout << "int i = " << i << endl;
33
34     double x = 1111111111;
35     cout << "double x = " << x << endl;
36     sgEndianSwap((unsigned long long *)&x);
37     cout << "double x = " << x << endl;
38     sgEndianSwap((unsigned long long *)&x);
39     cout << "double x = " << x << endl;
40 }