]> git.mxchange.org Git - simgear.git/blob - simgear/io/lowtest.cxx
Tidy up the autoconf/automake configuration a bit.
[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     cout << "sizeof(short) = " << sizeof(short) << endl;
27
28     short s = 1111;
29     cout << "short s = " << s << endl;
30     sgEndianSwap((unsigned short *)&s);
31     cout << "short s = " << s << endl;
32     sgEndianSwap((unsigned short *)&s);
33     cout << "short s = " << s << endl;
34
35     int i = 1111111;
36     cout << "int i = " << i << endl;
37     sgEndianSwap((unsigned int *)&i);
38     cout << "int i = " << i << endl;
39     sgEndianSwap((unsigned int *)&i);
40     cout << "int i = " << i << endl;
41
42     double x = 1111111111;
43     cout << "double x = " << x << endl;
44     sgEndianSwap((unsigned long long *)&x);
45     cout << "double x = " << x << endl;
46     sgEndianSwap((unsigned long long *)&x);
47     cout << "double x = " << x << endl;
48 }