1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * |
---|
4 | * |
---|
5 | * License notice: |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU General Public License |
---|
9 | * as published by the Free Software Foundation; either version 2 |
---|
10 | * of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
20 | * |
---|
21 | * Author: |
---|
22 | * An unknown man from the Ogre development crew |
---|
23 | * Co-authors: |
---|
24 | * Reto Grieder (OGRE --> ORXONOX) |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | /** |
---|
29 | @file OrxonoxPlatform.h |
---|
30 | @brief Various constants for compiler, architecture and platform. It's a mere |
---|
31 | copy of the file found in the Ogre source code (OgrePlatform.h). |
---|
32 | */ |
---|
33 | |
---|
34 | #ifndef _OrxonoxPlatform_H__ |
---|
35 | #define _OrxonoxPlatform_H__ |
---|
36 | |
---|
37 | namespace orxonox { |
---|
38 | /* Initial platform/compiler-related stuff to set. |
---|
39 | */ |
---|
40 | #define ORXONOX_PLATFORM_WIN32 1 |
---|
41 | #define ORXONOX_PLATFORM_LINUX 2 |
---|
42 | #define ORXONOX_PLATFORM_APPLE 3 |
---|
43 | |
---|
44 | #define ORXONOX_COMPILER_MSVC 1 |
---|
45 | #define ORXONOX_COMPILER_GNUC 2 |
---|
46 | #define ORXONOX_COMPILER_BORL 3 |
---|
47 | |
---|
48 | #define ORXONOX_ENDIAN_LITTLE 1 |
---|
49 | #define ORXONOX_ENDIAN_BIG 2 |
---|
50 | |
---|
51 | #define ORXONOX_ARCHITECTURE_32 1 |
---|
52 | #define ORXONOX_ARCHITECTURE_64 2 |
---|
53 | |
---|
54 | /* Finds the compiler type and version. |
---|
55 | */ |
---|
56 | #if defined( _MSC_VER ) |
---|
57 | # define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC |
---|
58 | # define ORXONOX_COMP_VER _MSC_VER |
---|
59 | |
---|
60 | #elif defined( __GNUC__ ) |
---|
61 | # define ORXONOX_COMPILER ORXONOX_COMPILER_GNUC |
---|
62 | # define ORXONOX_COMP_VER (((__GNUC__)*100) + \ |
---|
63 | (__GNUC_MINOR__*10) + \ |
---|
64 | __GNUC_PATCHLEVEL__) |
---|
65 | |
---|
66 | #elif defined( __BORLANDC__ ) |
---|
67 | # define ORXONOX_COMPILER ORXONOX_COMPILER_BORL |
---|
68 | # define ORXONOX_COMP_VER __BCPLUSPLUS__ |
---|
69 | |
---|
70 | #else |
---|
71 | # pragma error "No known compiler. Abort! Abort!" |
---|
72 | |
---|
73 | #endif |
---|
74 | |
---|
75 | /* See if we can use __forceinline or if we need to use __inline instead */ |
---|
76 | #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC |
---|
77 | # if ORXONOX_COMP_VER >= 1200 |
---|
78 | # define FORCEINLINE __forceinline |
---|
79 | # endif |
---|
80 | #elif defined(__MINGW32__) |
---|
81 | # if !defined(FORCEINLINE) |
---|
82 | # define FORCEINLINE __inline |
---|
83 | # endif |
---|
84 | #else |
---|
85 | # define FORCEINLINE __inline |
---|
86 | #endif |
---|
87 | |
---|
88 | /* Finds the current platform */ |
---|
89 | |
---|
90 | #if defined( __WIN32__ ) || defined( _WIN32 ) |
---|
91 | # define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32 |
---|
92 | |
---|
93 | #elif defined( __APPLE_CC__) |
---|
94 | # define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE |
---|
95 | |
---|
96 | #else |
---|
97 | # define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX |
---|
98 | #endif |
---|
99 | |
---|
100 | /* Find the arch type */ |
---|
101 | #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) |
---|
102 | # define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64 |
---|
103 | #else |
---|
104 | # define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_32 |
---|
105 | #endif |
---|
106 | |
---|
107 | // For generating compiler warnings - should work on any compiler |
---|
108 | // As a side note, if you start your message with 'Warning: ', the MSVC |
---|
109 | // IDE actually does catch a warning :) |
---|
110 | #define ORXONOX_QUOTE_INPLACE(x) # x |
---|
111 | #define ORXONOX_QUOTE(x) ORXONOX_QUOTE_INPLACE(x) |
---|
112 | #define ORXONOX_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" ) |
---|
113 | |
---|
114 | //---------------------------------------------------------------------------- |
---|
115 | // Windows Settings |
---|
116 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 |
---|
117 | |
---|
118 | // Win32 compilers use _DEBUG for specifying debug builds. |
---|
119 | # ifdef _DEBUG |
---|
120 | # define ORXONOX_DEBUG_MODE 1 |
---|
121 | # else |
---|
122 | # define ORXONOX_DEBUG_MODE 0 |
---|
123 | # endif |
---|
124 | |
---|
125 | // Disable unicode support on MingW at the moment, poorly supported in stdlibc++ |
---|
126 | // STLPORT fixes this though so allow if found |
---|
127 | // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h |
---|
128 | # if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION) |
---|
129 | # include<_mingw.h> |
---|
130 | # if defined(__MINGW32_TOOLBOX_UNICODE__) |
---|
131 | # define ORXONOX_UNICODE_SUPPORT 1 |
---|
132 | # else |
---|
133 | # define ORXONOX_UNICODE_SUPPORT 0 |
---|
134 | # endif |
---|
135 | # else |
---|
136 | # define ORXONOX_UNICODE_SUPPORT 1 |
---|
137 | # endif |
---|
138 | |
---|
139 | #endif |
---|
140 | //---------------------------------------------------------------------------- |
---|
141 | |
---|
142 | //---------------------------------------------------------------------------- |
---|
143 | // Linux/Apple Settings |
---|
144 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
145 | |
---|
146 | |
---|
147 | // A quick define to overcome different names for the same function |
---|
148 | # define stricmp strcasecmp |
---|
149 | |
---|
150 | // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when |
---|
151 | // specifying a debug build. |
---|
152 | // (??? this is wrong, on Linux debug builds aren't marked in any way unless |
---|
153 | // you mark it yourself any way you like it -- zap ???) |
---|
154 | # ifdef DEBUG |
---|
155 | # define ORXONOX_DEBUG_MODE 1 |
---|
156 | # else |
---|
157 | # define ORXONOX_DEBUG_MODE 0 |
---|
158 | # endif |
---|
159 | |
---|
160 | /* FIXME: Check what this actually is and whether we need it or not |
---|
161 | # if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
162 | # define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle" |
---|
163 | # else |
---|
164 | // ORXONOX_PLATFORM_LINUX |
---|
165 | # define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so" |
---|
166 | # endif |
---|
167 | */ |
---|
168 | |
---|
169 | // Always enable unicode support for the moment |
---|
170 | // Perhaps disable in old versions of gcc if necessary |
---|
171 | # define ORXONOX_UNICODE_SUPPORT 1 |
---|
172 | |
---|
173 | #endif |
---|
174 | |
---|
175 | //For apple, we always have a custom config.h file |
---|
176 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
177 | # include "config.h" |
---|
178 | #endif |
---|
179 | |
---|
180 | //---------------------------------------------------------------------------- |
---|
181 | |
---|
182 | //---------------------------------------------------------------------------- |
---|
183 | // Endian Settings |
---|
184 | // check for BIG_ENDIAN config flag, set ORXONOX_ENDIAN correctly |
---|
185 | #ifdef ORXONOX_CONFIG_BIG_ENDIAN |
---|
186 | # define ORXONOX_ENDIAN ORXONOX_ENDIAN_BIG |
---|
187 | #else |
---|
188 | # define ORXONOX_ENDIAN ORXONOX_ENDIAN_LITTLE |
---|
189 | #endif |
---|
190 | |
---|
191 | // Integer formats of fixed bit width |
---|
192 | typedef unsigned int uint32; |
---|
193 | typedef unsigned short uint16; |
---|
194 | typedef unsigned char uint8; |
---|
195 | |
---|
196 | #ifdef ORXONOX_DOUBLE_PRECISION |
---|
197 | typedef double Real; |
---|
198 | #else |
---|
199 | typedef float Real; |
---|
200 | #endif |
---|
201 | |
---|
202 | |
---|
203 | #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC |
---|
204 | // Turn off warnings generated by long std templates |
---|
205 | // This warns about truncation to 255 characters in debug/browse info |
---|
206 | //# pragma warning (disable : 4786) |
---|
207 | |
---|
208 | // Turn off warnings generated by long std templates |
---|
209 | // This warns about truncation to 255 characters in debug/browse info |
---|
210 | //# pragma warning (disable : 4503) |
---|
211 | |
---|
212 | // disable: "conversion from 'double' to 'float', possible loss of data |
---|
213 | //# pragma warning (disable : 4244) |
---|
214 | |
---|
215 | // disable: "conversion from 'size_t' to 'unsigned int', possible loss of data |
---|
216 | //# pragma warning (disable : 4267) |
---|
217 | |
---|
218 | // disable: "truncation from 'double' to 'float' |
---|
219 | //# pragma warning (disable : 4305) |
---|
220 | |
---|
221 | // disable: "<type> needs to have dll-interface to be used by clients' |
---|
222 | // Happens on STL member variables which are not public therefore is ok |
---|
223 | //# pragma warning (disable : 4251) |
---|
224 | |
---|
225 | // disable: "non dll-interface class used as base for dll-interface class" |
---|
226 | // Happens when deriving from Singleton because bug in compiler ignores |
---|
227 | // template export |
---|
228 | //# pragma warning (disable : 4275) |
---|
229 | |
---|
230 | // disable: "C++ Exception Specification ignored" |
---|
231 | // This is because MSVC 6 did not implement all the C++ exception |
---|
232 | // specifications in the ANSI C++ draft. |
---|
233 | //# pragma warning( disable : 4290 ) |
---|
234 | |
---|
235 | // disable: "no suitable definition provided for explicit template |
---|
236 | // instantiation request" Occurs in VC7 for no justifiable reason on all |
---|
237 | // #includes of Singleton |
---|
238 | //# pragma warning( disable: 4661) |
---|
239 | |
---|
240 | // disable: deprecation warnings when using CRT calls in VC8 |
---|
241 | // These show up on all C runtime lib code in VC8, disable since they clutter |
---|
242 | // the warnings with things we may not be able to do anything about (e.g. |
---|
243 | // generated code from nvparse etc). I doubt very much that these calls |
---|
244 | // will ever be actually removed from VC anyway, it would break too much code. |
---|
245 | //# pragma warning( disable: 4996) |
---|
246 | |
---|
247 | // disable: "conditional expression constant", always occurs on |
---|
248 | // ORXONOX_MUTEX_CONDITIONAL when no threading enabled |
---|
249 | //# pragma warning (disable : 201) |
---|
250 | |
---|
251 | #endif |
---|
252 | |
---|
253 | |
---|
254 | // Create a logical xor operator |
---|
255 | #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC |
---|
256 | # define XOR ^ |
---|
257 | #elif ORXONOX_COMPILER == ORXONOX_COMPILER_GCC |
---|
258 | # define XOR xor |
---|
259 | #else |
---|
260 | # define XOR ^ |
---|
261 | #endif |
---|
262 | |
---|
263 | } /* namespace orxonox */ |
---|
264 | |
---|
265 | #endif /* _OrxonoxPlatform_H__ */ |
---|