vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
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
34typedef char vrpn_int8;
35typedef unsigned char vrpn_uint8;
36typedef short vrpn_int16;
37typedef unsigned short vrpn_uint16;
38typedef int vrpn_int32;
39typedef unsigned int vrpn_uint32;
40typedef float vrpn_float32;
41typedef double vrpn_float64;
42#endif
43
44#ifdef hpux
45#define VRPN_ARCH hpux
46typedef char vrpn_int8;
47typedef unsigned char vrpn_uint8;
48typedef short vrpn_int16;
49typedef unsigned short vrpn_uint16;
50typedef int vrpn_int32;
51typedef unsigned int vrpn_uint32;
52typedef float vrpn_float32;
53typedef double vrpn_float64;
54#endif
55
56// For PixelFlow aCC compiler
57#ifdef __hpux
58#undef VRPN_ARCH
59#define VRPN_ARCH __hpux
60typedef char vrpn_int8;
61typedef unsigned char vrpn_uint8;
62typedef short vrpn_int16;
63typedef unsigned short vrpn_uint16;
64typedef int vrpn_int32;
65typedef unsigned int vrpn_uint32;
66typedef float vrpn_float32;
67typedef double vrpn_float64;
68#endif
69
70#ifdef sparc
71#define VRPN_ARCH sparc
72typedef char vrpn_int8;
73typedef unsigned char vrpn_uint8;
74typedef short vrpn_int16;
75typedef unsigned short vrpn_uint16;
76typedef int vrpn_int32;
77typedef unsigned int vrpn_uint32;
78typedef float vrpn_float32;
79typedef double vrpn_float64;
80#endif
81
82#ifdef linux
83#define VRPN_ARCH linux
84typedef char vrpn_int8;
85typedef unsigned char vrpn_uint8;
86typedef short vrpn_int16;
87typedef unsigned short vrpn_uint16;
88typedef int vrpn_int32;
89typedef unsigned int vrpn_uint32;
90typedef float vrpn_float32;
91typedef double vrpn_float64;
92#endif
93
94#ifdef _AIX
95#define VRPN_ARCH aix
96typedef char vrpn_int8;
97typedef unsigned char vrpn_uint8;
98typedef short vrpn_int16;
99typedef unsigned short vrpn_uint16;
100typedef int vrpn_int32;
101typedef unsigned int vrpn_uint32;
102typedef float vrpn_float32;
103typedef 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
118typedef char vrpn_int8;
119typedef unsigned char vrpn_uint8;
120typedef short vrpn_int16;
121typedef unsigned short vrpn_uint16;
122typedef int vrpn_int32;
123typedef unsigned int vrpn_uint32;
124typedef float vrpn_float32;
125typedef 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
133typedef char vrpn_int8;
134typedef unsigned char vrpn_uint8;
135typedef short vrpn_int16;
136typedef unsigned short vrpn_uint16;
137typedef int vrpn_int32;
138typedef unsigned int vrpn_uint32;
139typedef float vrpn_float32;
140typedef double vrpn_float64;
141#endif
142
143#ifdef __APPLE__
144#define VRPN_ARCH MacOSX
145typedef char vrpn_int8;
146typedef unsigned char vrpn_uint8;
147typedef short vrpn_int16;
148typedef unsigned short vrpn_uint16;
149typedef int vrpn_int32;
150typedef unsigned int vrpn_uint32;
151typedef float vrpn_float32;
152typedef double vrpn_float64;
153#endif
154
155// Architecture of last resort.
156#ifndef VRPN_ARCH
157#ifdef __GNUC__
158#define VRPN_ARCH _WIN32
159typedef char vrpn_int8;
160typedef unsigned char vrpn_uint8;
161typedef short vrpn_int16;
162typedef unsigned short vrpn_uint16;
163typedef int vrpn_int32;
164typedef unsigned int vrpn_uint32;
165typedef float vrpn_float32;
166typedef 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
183typedef vrpn_int16 vrpn_bool;
184
185const vrpn_int16 vrpn_true = 1;
186const vrpn_int16 vrpn_false = 0;
187const vrpn_int16 vrpn_TRUE = 1;
188const vrpn_int16 vrpn_FALSE = 0;
189const vrpn_int16 VRPN_TRUE = 1;
190const 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