vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Types.h
Go to the documentation of this file.
1 #ifndef VRPN_TYPES_H
2 #define VRPN_TYPES_H
3 
4 #include "vrpn_Configure.h"
5 
6 //------------------------------------------------------------------
7 // Do a test for a C++ compiler first, to ensure it's the first
8 // error message. Otherwise, the error messages you get are
9 // completely cryptic.
10 //------------------------------------------------------------------
11 #ifndef __cplusplus
12 #ifndef VRPN_IGNORE_NO_CPLUSPLUS
13 #error Need to compile with a C++ compiler, not a C compiler. The problem is that in Windows, filenames are case-insensitive. So the compiler cannot tell mumble.c from mumble.C. Visual Studio decided to make .cpp (which used to mean run the C preprocessor) mean C++ and both .c and .C mean C. The other problem is that when you insert a new file into a project, it FOR THAT FILE makes an override. The project settings say C++ but if you right-click on the file itself it has an override to compile with C. This needs to be changed for both the .C file and the .h file.
14 #endif
15 #endif
16 
17 //------------------------------------------------------------------
18 // This section contains definitions for architecture-dependent
19 // types. It is important that the data sent over a vrpn_Connection
20 // be of the same size on all hosts sending and receiving it. Since
21 // C++ does not constrain the size of 'int', 'long', 'double' and
22 // so forth, we create new types here that are defined correctly for
23 // each architecture and use them for all data that might be sent
24 // across a connection.
25 // Part of porting VRPN to a new architecture is defining the
26 // types below on that architecture in such as way that the compiler
27 // can determine which machine type it is on.
28 //------------------------------------------------------------------
29 
30 #undef VRPN_ARCH
31 
32 #ifdef sgi
33 #define VRPN_ARCH sgi
34 typedef char vrpn_int8;
35 typedef unsigned char vrpn_uint8;
36 typedef short vrpn_int16;
37 typedef unsigned short vrpn_uint16;
38 typedef int vrpn_int32;
39 typedef unsigned int vrpn_uint32;
40 typedef float vrpn_float32;
41 typedef double vrpn_float64;
42 #endif
43 
44 #ifdef hpux
45 #define VRPN_ARCH hpux
46 typedef char vrpn_int8;
47 typedef unsigned char vrpn_uint8;
48 typedef short vrpn_int16;
49 typedef unsigned short vrpn_uint16;
50 typedef int vrpn_int32;
51 typedef unsigned int vrpn_uint32;
52 typedef float vrpn_float32;
53 typedef double vrpn_float64;
54 #endif
55 
56 // For PixelFlow aCC compiler
57 #ifdef __hpux
58 #undef VRPN_ARCH
59 #define VRPN_ARCH __hpux
60 typedef char vrpn_int8;
61 typedef unsigned char vrpn_uint8;
62 typedef short vrpn_int16;
63 typedef unsigned short vrpn_uint16;
64 typedef int vrpn_int32;
65 typedef unsigned int vrpn_uint32;
66 typedef float vrpn_float32;
67 typedef double vrpn_float64;
68 #endif
69 
70 #ifdef sparc
71 #define VRPN_ARCH sparc
72 typedef char vrpn_int8;
73 typedef unsigned char vrpn_uint8;
74 typedef short vrpn_int16;
75 typedef unsigned short vrpn_uint16;
76 typedef int vrpn_int32;
77 typedef unsigned int vrpn_uint32;
78 typedef float vrpn_float32;
79 typedef double vrpn_float64;
80 #endif
81 
82 #ifdef linux
83 #define VRPN_ARCH linux
84 typedef char vrpn_int8;
85 typedef unsigned char vrpn_uint8;
86 typedef short vrpn_int16;
87 typedef unsigned short vrpn_uint16;
88 typedef int vrpn_int32;
89 typedef unsigned int vrpn_uint32;
90 typedef float vrpn_float32;
91 typedef double vrpn_float64;
92 #endif
93 
94 #ifdef _AIX
95 #define VRPN_ARCH aix
96 typedef char vrpn_int8;
97 typedef unsigned char vrpn_uint8;
98 typedef short vrpn_int16;
99 typedef unsigned short vrpn_uint16;
100 typedef int vrpn_int32;
101 typedef unsigned int vrpn_uint32;
102 typedef float vrpn_float32;
103 typedef double vrpn_float64;
104 #endif
105 
106 // _WIN32 is defined for all compilers for Windows (cygnus g++ included)
107 // WIN32 (sans underline) is defined only by the Windows VC++ compiler.
108 //
109 // DO NOT EVER USE WIN32
110 //
111 // It is too hard to differentiate from _WIN32, and may not actually be
112 // defined by VC++ (it's a project option). If you use WIN32 to distinguish
113 // between VC++ and cygwin/g++, may your wrists quickly develop a nerve
114 // disorder that prevents you from ever typing again ;)
115 //
116 #ifdef _WIN32
117 #define VRPN_ARCH _WIN32
118 typedef char vrpn_int8;
119 typedef unsigned char vrpn_uint8;
120 typedef short vrpn_int16;
121 typedef unsigned short vrpn_uint16;
122 typedef int vrpn_int32;
123 typedef unsigned int vrpn_uint32;
124 typedef float vrpn_float32;
125 typedef double vrpn_float64;
126 #endif
127 
128 #if defined(FreeBSD) || defined(__FreeBSD__)
129 #ifndef FreeBSD
130 #define FreeBSD
131 #endif
132 #define VRPN_ARCH FreeBSD
133 typedef char vrpn_int8;
134 typedef unsigned char vrpn_uint8;
135 typedef short vrpn_int16;
136 typedef unsigned short vrpn_uint16;
137 typedef int vrpn_int32;
138 typedef unsigned int vrpn_uint32;
139 typedef float vrpn_float32;
140 typedef double vrpn_float64;
141 #endif
142 
143 #ifdef __APPLE__
144 #define VRPN_ARCH MacOSX
145 typedef char vrpn_int8;
146 typedef unsigned char vrpn_uint8;
147 typedef short vrpn_int16;
148 typedef unsigned short vrpn_uint16;
149 typedef int vrpn_int32;
150 typedef unsigned int vrpn_uint32;
151 typedef float vrpn_float32;
152 typedef double vrpn_float64;
153 #endif
154 
155 // Architecture of last resort.
156 #ifndef VRPN_ARCH
157 #ifdef __GNUC__
158 #define VRPN_ARCH _WIN32
159 typedef char vrpn_int8;
160 typedef unsigned char vrpn_uint8;
161 typedef short vrpn_int16;
162 typedef unsigned short vrpn_uint16;
163 typedef int vrpn_int32;
164 typedef unsigned int vrpn_uint32;
165 typedef float vrpn_float32;
166 typedef double vrpn_float64;
167 #endif
168 #endif
169 
170 #ifndef VRPN_ARCH
171 #error Need to define architecture-dependent sizes in this file
172 #endif
173 
174 // Prevent use of this macro outside this file;
175 // if you need to distinguish more types, then define new types in this file.
176 
177 #undef VRPN_ARCH
178 
179 // *******************************************************
180 // you should NOT need to modify anything below this point
181 // *******************************************************
182 #ifdef __cplusplus
183 typedef vrpn_int16 vrpn_bool;
184 
185 const vrpn_int16 vrpn_true = 1;
186 const vrpn_int16 vrpn_false = 0;
187 const vrpn_int16 vrpn_TRUE = 1;
188 const vrpn_int16 vrpn_FALSE = 0;
189 const vrpn_int16 VRPN_TRUE = 1;
190 const vrpn_int16 VRPN_FALSE = 0;
191 #endif
192 
193 // should we add a success & fail?
194 
195 // [juliano 10/9/99] The vrpn bool variables can not actually be fully
196 // optimized away, because the compiler is not allowed to assume their
197 // values don't change.
198 //
199 // [juliano 11/28/99] Perhaps the optimization can be done if they are
200 // static? I don't know enough about what compilers can/cannot do today.
201 //
202 // If you are willing to assume templates, there is an alternative using
203 // a traits class that does make the optimization possible (and likely).
204 //
205 // If you don't want to use templates, but still want the sizeof
206 // these things be vrpn_int16, you can use macros like this.
207 //
208 // #define vrpn_false /*false*/vrpn_int16(0)
209 // #define vrpn_true /*true*/vrpn_int16(1)
210 //
211 // With this method, you will still be able to tell, in the
212 // compiler error messages, what the real code contains.
213 //
214 // If you don't care about them being a different type than
215 // vrpn_int16 (probably not a good idea), you can use this technique,
216 // which guarantees optimizations can be performed.
217 //
218 // enum vrpn_bool_constants_t{
219 // vrpn_false=0, vrpn_FALSE=0, VRPN_FALSE=0,
220 // vrpn_true=1, vrpn_TRUE=1, VRPN_TRUE=1 };
221 //
222 
223 #endif // VRPN_TYPES_H