OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgrePlatform.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Platform_H_
29 #define __Platform_H_
30 
31 #include "OgreConfig.h"
32 
33 namespace Ogre {
34 /* Initial platform/compiler-related stuff to set.
35 */
36 #define OGRE_PLATFORM_WIN32 1
37 #define OGRE_PLATFORM_LINUX 2
38 #define OGRE_PLATFORM_APPLE 3
39 #define OGRE_PLATFORM_APPLE_IOS 4
40 #define OGRE_PLATFORM_ANDROID 5
41 #define OGRE_PLATFORM_NACL 6
42 #define OGRE_PLATFORM_WINRT 7
43 #define OGRE_PLATFORM_FLASHCC 8
44 
45 #define OGRE_COMPILER_MSVC 1
46 #define OGRE_COMPILER_GNUC 2
47 #define OGRE_COMPILER_BORL 3
48 #define OGRE_COMPILER_WINSCW 4
49 #define OGRE_COMPILER_GCCE 5
50 #define OGRE_COMPILER_CLANG 6
51 
52 #define OGRE_ENDIAN_LITTLE 1
53 #define OGRE_ENDIAN_BIG 2
54 
55 #define OGRE_ARCHITECTURE_32 1
56 #define OGRE_ARCHITECTURE_64 2
57 
58 /* Finds the compiler type and version.
59 */
60 #if (defined( __WIN32__ ) || defined( _WIN32 )) && defined(__ANDROID__) // We are using NVTegra
61 # define OGRE_COMPILER OGRE_COMPILER_GNUC
62 # define OGRE_COMP_VER 470
63 #elif defined( __GCCE__ )
64 # define OGRE_COMPILER OGRE_COMPILER_GCCE
65 # define OGRE_COMP_VER _MSC_VER
66 //# include <staticlibinit_gcce.h> // This is a GCCE toolchain workaround needed when compiling with GCCE
67 #elif defined( __WINSCW__ )
68 # define OGRE_COMPILER OGRE_COMPILER_WINSCW
69 # define OGRE_COMP_VER _MSC_VER
70 #elif defined( _MSC_VER )
71 # define OGRE_COMPILER OGRE_COMPILER_MSVC
72 # define OGRE_COMP_VER _MSC_VER
73 #elif defined( __clang__ )
74 # define OGRE_COMPILER OGRE_COMPILER_CLANG
75 # define OGRE_COMP_VER (((__clang_major__)*100) + \
76  (__clang_minor__*10) + \
77  __clang_patchlevel__)
78 #elif defined( __GNUC__ )
79 # define OGRE_COMPILER OGRE_COMPILER_GNUC
80 # define OGRE_COMP_VER (((__GNUC__)*100) + \
81  (__GNUC_MINOR__*10) + \
82  __GNUC_PATCHLEVEL__)
83 #elif defined( __BORLANDC__ )
84 # define OGRE_COMPILER OGRE_COMPILER_BORL
85 # define OGRE_COMP_VER __BCPLUSPLUS__
86 # define __FUNCTION__ __FUNC__
87 #else
88 # pragma error "No known compiler. Abort! Abort!"
89 
90 #endif
91 
92 /* See if we can use __forceinline or if we need to use __inline instead */
93 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
94 # if OGRE_COMP_VER >= 1200
95 # define FORCEINLINE __forceinline
96 # endif
97 #elif defined(__MINGW32__)
98 # if !defined(FORCEINLINE)
99 # define FORCEINLINE __inline
100 # endif
101 #else
102 # define FORCEINLINE __inline
103 #endif
104 
105 /* define OGRE_NORETURN macro */
106 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
107 # define OGRE_NORETURN __declspec(noreturn)
108 #elif OGRE_COMPILER == OGRE_COMPILER_GCC || OGRE_COMPILER == OGRE_COMPILER_CLANG
109 # define OGRE_NORETURN __attribute__((noreturn))
110 #else
111 # define OGRE_NORETURN
112 #endif
113 
114 /* Finds the current platform */
115 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(__ANDROID__)
116 # if defined(WINAPI_FAMILY)
117 # define __OGRE_HAVE_DIRECTXMATH 1
118 # include <winapifamily.h>
119 # if WINAPI_FAMILY == WINAPI_FAMILY_APP|| WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
120 # define DESKTOP_APP 1
121 # define PHONE 2
122 # define OGRE_PLATFORM OGRE_PLATFORM_WINRT
123 # ifndef _CRT_SECURE_NO_WARNINGS
124 # define _CRT_SECURE_NO_WARNINGS
125 # endif
126 # ifndef _SCL_SECURE_NO_WARNINGS
127 # define _SCL_SECURE_NO_WARNINGS
128 # endif
129 # if WINAPI_FAMILY == WINAPI_FAMILY_APP
130 # define OGRE_WINRT_TARGET_TYPE DESKTOP_APP
131 # endif
132 # if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
133 # define OGRE_WINRT_TARGET_TYPE PHONE
134 # endif
135 # else
136 # define OGRE_PLATFORM OGRE_PLATFORM_WIN32
137 # endif
138 # else
139 # define OGRE_PLATFORM OGRE_PLATFORM_WIN32
140 # endif
141 #elif defined(__FLASHCC__)
142 # define OGRE_PLATFORM OGRE_PLATFORM_FLASHCC
143 #elif defined( __APPLE_CC__)
144  // Device Simulator
145  // Both requiring OS version 6.0 or greater
146 # if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 60000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
147 # define OGRE_PLATFORM OGRE_PLATFORM_APPLE_IOS
148 # else
149 # define OGRE_PLATFORM OGRE_PLATFORM_APPLE
150 # endif
151 #elif defined(__ANDROID__)
152 # define OGRE_PLATFORM OGRE_PLATFORM_ANDROID
153 #elif defined( __native_client__ )
154 # define OGRE_PLATFORM OGRE_PLATFORM_NACL
155 # ifndef OGRE_STATIC_LIB
156 # error OGRE must be built as static for NaCl (OGRE_STATIC=true in CMake)
157 # endif
158 # ifdef OGRE_BUILD_RENDERSYSTEM_D3D9
159 # error D3D9 is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_D3D9 false in CMake)
160 # endif
161 # ifdef OGRE_BUILD_RENDERSYSTEM_GL
162 # error OpenGL is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_GL=false in CMake)
163 # endif
164 # ifndef OGRE_BUILD_RENDERSYSTEM_GLES2
165 # error GLES2 render system is required for NaCl (OGRE_BUILD_RENDERSYSTEM_GLES2=false in CMake)
166 # endif
167 #else
168 # define OGRE_PLATFORM OGRE_PLATFORM_LINUX
169 #endif
170 
171  /* Find the arch type */
172 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) || defined(__arm64__) || defined(_aarch64_) || defined(__mips64) || defined(__mips64_)
173 # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64
174 #else
175 # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32
176 #endif
177 
178 // For generating compiler warnings - should work on any compiler
179 // As a side note, if you start your message with 'Warning: ', the MSVC
180 // IDE actually does catch a warning :)
181 #define OGRE_QUOTE_INPLACE(x) # x
182 #define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x)
183 #define OGRE_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
184 
185 // For marking functions as deprecated
186 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
187 # define OGRE_DEPRECATED __declspec(deprecated)
188 #elif OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG
189 # define OGRE_DEPRECATED __attribute__ ((deprecated))
190 #else
191 # pragma message("WARNING: You need to implement OGRE_DEPRECATED for this compiler")
192 # define OGRE_DEPRECATED
193 #endif
194 
195 //----------------------------------------------------------------------------
196 // Windows Settings
197 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
198 
199 // If we're not including this from a client build, specify that the stuff
200 // should get exported. Otherwise, import it.
201 # if defined( OGRE_STATIC_LIB )
202  // Linux compilers don't have symbol import/export directives.
203 # define _OgreExport
204 # define _OgrePrivate
205 # else
206 # if defined( OGRE_NONCLIENT_BUILD )
207 # define _OgreExport __declspec( dllexport )
208 # else
209 # if defined( __MINGW32__ )
210 # define _OgreExport
211 # else
212 # define _OgreExport __declspec( dllimport )
213 # endif
214 # endif
215 # define _OgrePrivate
216 # endif
217 // Win32 compilers use _DEBUG for specifying debug builds.
218 // for MinGW, we set DEBUG
219 # if defined(_DEBUG) || defined(DEBUG)
220 # define OGRE_DEBUG_MODE 1
221 # else
222 # define OGRE_DEBUG_MODE 0
223 # endif
224 
225 // Disable unicode support on MingW for GCC 3, poorly supported in stdlibc++
226 // STLPORT fixes this though so allow if found
227 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLBOX_UNICODE__ in _mingw.h
228 // GCC 4 is also fine
229 #if defined(__MINGW32__)
230 # if OGRE_COMP_VER < 400
231 # if !defined(_STLPORT_VERSION)
232 # include<_mingw.h>
233 # if defined(__MINGW32_TOOLBOX_UNICODE__) || OGRE_COMP_VER > 345
234 # define OGRE_UNICODE_SUPPORT 1
235 # else
236 # define OGRE_UNICODE_SUPPORT 0
237 # endif
238 # else
239 # define OGRE_UNICODE_SUPPORT 1
240 # endif
241 # else
242 # define OGRE_UNICODE_SUPPORT 1
243 # endif
244 #else
245 # define OGRE_UNICODE_SUPPORT 1
246 #endif
247 
248 #endif // OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
249 
250 //----------------------------------------------------------------------------
251 // Linux/Apple/iOS/Android/NaCl Settings
252 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS || \
253  OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_NACL || OGRE_PLATFORM == OGRE_PLATFORM_FLASHCC
254 
255 // Enable GCC symbol visibility
256 # if defined( OGRE_GCC_VISIBILITY )
257 # define _OgreExport __attribute__ ((visibility("default")))
258 # define _OgrePrivate __attribute__ ((visibility("hidden")))
259 # else
260 # define _OgreExport
261 # define _OgrePrivate
262 # endif
263 
264 // A quick define to overcome different names for the same function
265 # define stricmp strcasecmp
266 
267 # ifdef DEBUG
268 # define OGRE_DEBUG_MODE 1
269 # else
270 # define OGRE_DEBUG_MODE 0
271 # endif
272 
273 // Always enable unicode support for the moment
274 // Perhaps disable in old versions of gcc if necessary
275 #define OGRE_UNICODE_SUPPORT 1
276 
277 #endif
278 
279 //----------------------------------------------------------------------------
280 // Android Settings
281 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
282 # ifdef OGRE_UNICODE_SUPPORT
283 # undef OGRE_UNICODE_SUPPORT
284 # endif
285 # define OGRE_UNICODE_SUPPORT 1
286  // A quick define to overcome different names for the same function
287 # define stricmp strcasecmp
288 # ifdef DEBUG
289 # define OGRE_DEBUG_MODE 1
290 # else
291 # define OGRE_DEBUG_MODE 0
292 # endif
293 # ifndef CLOCKS_PER_SEC
294 # define CLOCKS_PER_SEC 1000
295 # endif
296 #endif
297 
298 //----------------------------------------------------------------------------
299 // FlashCC Settings
300 #if OGRE_PLATFORM == OGRE_PLATFORM_FLASHCC
301 # ifdef OGRE_UNICODE_SUPPORT
302 # undef OGRE_UNICODE_SUPPORT
303 # endif
304 # define OGRE_UNICODE_SUPPORT 0
305 # ifdef DEBUG
306 # define OGRE_DEBUG_MODE 1
307 # else
308 # define OGRE_DEBUG_MODE 0
309 # endif
310 #endif
311 
312 #ifndef __OGRE_HAVE_DIRECTXMATH
313 # define __OGRE_HAVE_DIRECTXMATH 0
314 #endif
315 
316 //----------------------------------------------------------------------------
317 // Endian Settings
318 // check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly
319 #ifdef OGRE_CONFIG_BIG_ENDIAN
320 # define OGRE_ENDIAN OGRE_ENDIAN_BIG
321 #else
322 # define OGRE_ENDIAN OGRE_ENDIAN_LITTLE
323 #endif
324 
325 //----------------------------------------------------------------------------
326 // Set the default locale for strings
327 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
328 // Locales are not supported by the C lib you have to go through JNI.
329 # define OGRE_DEFAULT_LOCALE ""
330 #else
331 # define OGRE_DEFAULT_LOCALE "C"
332 #endif
333 
334 //----------------------------------------------------------------------------
335 // Library suffixes
336 // "_d" for debug builds, nothing otherwise
337 #if OGRE_DEBUG_MODE
338 # define OGRE_BUILD_SUFFIX "_d"
339 #else
340 # define OGRE_BUILD_SUFFIX ""
341 #endif
342 
343 // Integer formats of fixed bit width
344 typedef unsigned int uint32;
345 typedef unsigned short uint16;
346 typedef unsigned char uint8;
347 typedef int int32;
348 typedef short int16;
349 typedef signed char int8;
350 // define uint64 type
351 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
352  typedef unsigned __int64 uint64;
353  typedef __int64 int64;
354 #else
355  typedef unsigned long long uint64;
356  typedef long long int64;
357 #endif
358 
359 // Disable these warnings (too much noise)
360 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
361 #ifndef _CRT_SECURE_NO_WARNINGS
362 # define _CRT_SECURE_NO_WARNINGS
363 #endif
364 #ifndef _SCL_SECURE_NO_WARNINGS
365 # define _SCL_SECURE_NO_WARNINGS
366 #endif
367 // Turn off warnings generated by long std templates
368 // This warns about truncation to 255 characters in debug/browse info
369 # pragma warning (disable : 4786)
370 // Turn off warnings generated by long std templates
371 // This warns about truncation to 255 characters in debug/browse info
372 # pragma warning (disable : 4503)
373 // disable: "<type> needs to have dll-interface to be used by clients'
374 // Happens on STL member variables which are not public therefore is ok
375 # pragma warning (disable : 4251)
376 // disable: "non dll-interface class used as base for dll-interface class"
377 // Happens when deriving from Singleton because bug in compiler ignores
378 // template export
379 # pragma warning (disable : 4275)
380 // disable: "C++ Exception Specification ignored"
381 // This is because MSVC 6 did not implement all the C++ exception
382 // specifications in the ANSI C++ draft.
383 # pragma warning( disable : 4290 )
384 // disable: "no suitable definition provided for explicit template
385 // instantiation request" Occurs in VC7 for no justifiable reason on all
386 // #includes of Singleton
387 # pragma warning( disable: 4661)
388 // disable: deprecation warnings when using CRT calls in VC8
389 // These show up on all C runtime lib code in VC8, disable since they clutter
390 // the warnings with things we may not be able to do anything about (e.g.
391 // generated code from nvparse etc). I doubt very much that these calls
392 // will ever be actually removed from VC anyway, it would break too much code.
393 # pragma warning( disable: 4996)
394 // disable: "conditional expression constant", always occurs on
395 // OGRE_MUTEX_CONDITIONAL when no threading enabled
396 # pragma warning (disable : 201)
397 // disable: "unreferenced formal parameter"
398 // Many versions of VC have bugs which generate this error in cases where they shouldn't
399 # pragma warning (disable : 4100)
400 // disable: "behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized"
401 // We have this issue in OgreMemorySTLAlloc.h - so we see it over and over
402 # pragma warning (disable : 4345)
403 #endif
404 
405 }
406 
407 #endif
unsigned char uint8
Definition: OgrePlatform.h:346
unsigned int uint32
Definition: OgrePlatform.h:344
long long int64
Definition: OgrePlatform.h:356
short int16
Definition: OgrePlatform.h:348
unsigned long long uint64
Definition: OgrePlatform.h:355
signed char int8
Definition: OgrePlatform.h:349
int int32
Definition: OgrePlatform.h:347
unsigned short uint16
Definition: OgrePlatform.h:345