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