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-2013 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 
44 #define OGRE_COMPILER_MSVC 1
45 #define OGRE_COMPILER_GNUC 2
46 #define OGRE_COMPILER_BORL 3
47 #define OGRE_COMPILER_WINSCW 4
48 #define OGRE_COMPILER_GCCE 5
49 #define OGRE_COMPILER_CLANG 6
50 
51 #define OGRE_ENDIAN_LITTLE 1
52 #define OGRE_ENDIAN_BIG 2
53 
54 #define OGRE_ARCHITECTURE_32 1
55 #define OGRE_ARCHITECTURE_64 2
56 
57 /* Finds the compiler type and version.
58 */
59 #if defined( __GCCE__ )
60 # define OGRE_COMPILER OGRE_COMPILER_GCCE
61 # define OGRE_COMP_VER _MSC_VER
62 //# include <staticlibinit_gcce.h> // This is a GCCE toolchain workaround needed when compiling with GCCE
63 #elif defined( __WINSCW__ )
64 # define OGRE_COMPILER OGRE_COMPILER_WINSCW
65 # define OGRE_COMP_VER _MSC_VER
66 #elif defined( _MSC_VER )
67 # define OGRE_COMPILER OGRE_COMPILER_MSVC
68 # define OGRE_COMP_VER _MSC_VER
69 #elif defined( __clang__ )
70 # define OGRE_COMPILER OGRE_COMPILER_CLANG
71 # define OGRE_COMP_VER (((__clang_major__)*100) + \
72  (__clang_minor__*10) + \
73  __clang_patchlevel__)
74 #elif defined( __GNUC__ )
75 # define OGRE_COMPILER OGRE_COMPILER_GNUC
76 # define OGRE_COMP_VER (((__GNUC__)*100) + \
77  (__GNUC_MINOR__*10) + \
78  __GNUC_PATCHLEVEL__)
79 #elif defined( __BORLANDC__ )
80 # define OGRE_COMPILER OGRE_COMPILER_BORL
81 # define OGRE_COMP_VER __BCPLUSPLUS__
82 # define __FUNCTION__ __FUNC__
83 #else
84 # pragma error "No known compiler. Abort! Abort!"
85 
86 #endif
87 
88 /* See if we can use __forceinline or if we need to use __inline instead */
89 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
90 # if OGRE_COMP_VER >= 1200
91 # define FORCEINLINE __forceinline
92 # endif
93 #elif defined(__MINGW32__)
94 # if !defined(FORCEINLINE)
95 # define FORCEINLINE __inline
96 # endif
97 #else
98 # define FORCEINLINE __inline
99 #endif
100 
101 /* Finds the current platform */
102 #if defined( __WIN32__ ) || defined( _WIN32 )
103 # if defined(WINAPI_FAMILY)
104 # define __OGRE_HAVE_DIRECTXMATH 1
105 # include <winapifamily.h>
106 # if WINAPI_FAMILY == WINAPI_FAMILY_APP|| WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
107 # define DESKTOP_APP 1
108 # define PHONE 2
109 # define OGRE_PLATFORM OGRE_PLATFORM_WINRT
110 # define _CRT_SECURE_NO_WARNINGS
111 # define _SCL_SECURE_NO_WARNINGS
112 # if WINAPI_FAMILY == WINAPI_FAMILY_APP
113 # define OGRE_WINRT_TARGET_TYPE DESKTOP_APP
114 # endif
115 # if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
116 # define OGRE_WINRT_TARGET_TYPE PHONE
117 # endif
118 # else
119 # define OGRE_PLATFORM OGRE_PLATFORM_WIN32
120 # endif
121 # else
122 # define OGRE_PLATFORM OGRE_PLATFORM_WIN32
123 # endif
124 #elif defined(__FLASHCC__)
125 # define OGRE_PLATFORM OGRE_PLATFORM_FLASHCC
126 #elif defined( __APPLE_CC__)
127  // Device Simulator
128  // Both requiring OS version 6.0 or greater
129 # if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 60000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
130 # define OGRE_PLATFORM OGRE_PLATFORM_APPLE_IOS
131 # else
132 # define OGRE_PLATFORM OGRE_PLATFORM_APPLE
133 # endif
134 #elif defined(__ANDROID__)
135 # define OGRE_PLATFORM OGRE_PLATFORM_ANDROID
136 #elif defined( __native_client__ )
137 # define OGRE_PLATFORM OGRE_PLATFORM_NACL
138 # ifndef OGRE_STATIC_LIB
139 # error OGRE must be built as static for NaCl (OGRE_STATIC=true in CMake)
140 # endif
141 # ifdef OGRE_BUILD_RENDERSYSTEM_D3D9
142 # error D3D9 is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_D3D9 false in CMake)
143 # endif
144 # ifdef OGRE_BUILD_RENDERSYSTEM_GL
145 # error OpenGL is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_GL=false in CMake)
146 # endif
147 # ifndef OGRE_BUILD_RENDERSYSTEM_GLES2
148 # error GLES2 render system is required for NaCl (OGRE_BUILD_RENDERSYSTEM_GLES2=false in CMake)
149 # endif
150 #else
151 # define OGRE_PLATFORM OGRE_PLATFORM_LINUX
152 #endif
153 
154  /* Find the arch type */
155 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
156 # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64
157 #else
158 # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32
159 #endif
160 
161 // For generating compiler warnings - should work on any compiler
162 // As a side note, if you start your message with 'Warning: ', the MSVC
163 // IDE actually does catch a warning :)
164 #define OGRE_QUOTE_INPLACE(x) # x
165 #define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x)
166 #define OGRE_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
167 
168 // For marking functions as deprecated
169 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
170 # define OGRE_DEPRECATED(func) __declspec(deprecated) func
171 #elif OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG
172 # define OGRE_DEPRECATED(func) func __attribute__ ((deprecated))
173 #else
174 # pragma message("WARNING: You need to implement OGRE_DEPRECATED for this compiler")
175 # define OGRE_DEPRECATED(func) func
176 #endif
177 
178 //----------------------------------------------------------------------------
179 // Windows Settings
180 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
181 
182 // If we're not including this from a client build, specify that the stuff
183 // should get exported. Otherwise, import it.
184 # if defined( OGRE_STATIC_LIB )
185  // Linux compilers don't have symbol import/export directives.
186 # define _OgreExport
187 # define _OgrePrivate
188 # else
189 # if defined( OGRE_NONCLIENT_BUILD )
190 # define _OgreExport __declspec( dllexport )
191 # else
192 # if defined( __MINGW32__ )
193 # define _OgreExport
194 # else
195 # define _OgreExport __declspec( dllimport )
196 # endif
197 # endif
198 # define _OgrePrivate
199 # endif
200 // Win32 compilers use _DEBUG for specifying debug builds.
201 // for MinGW, we set DEBUG
202 # if defined(_DEBUG) || defined(DEBUG)
203 # define OGRE_DEBUG_MODE 1
204 # else
205 # define OGRE_DEBUG_MODE 0
206 # endif
207 
208 // Disable unicode support on MingW for GCC 3, poorly supported in stdlibc++
209 // STLPORT fixes this though so allow if found
210 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLBOX_UNICODE__ in _mingw.h
211 // GCC 4 is also fine
212 #if defined(__MINGW32__)
213 # if OGRE_COMP_VER < 400
214 # if !defined(_STLPORT_VERSION)
215 # include<_mingw.h>
216 # if defined(__MINGW32_TOOLBOX_UNICODE__) || OGRE_COMP_VER > 345
217 # define OGRE_UNICODE_SUPPORT 1
218 # else
219 # define OGRE_UNICODE_SUPPORT 0
220 # endif
221 # else
222 # define OGRE_UNICODE_SUPPORT 1
223 # endif
224 # else
225 # define OGRE_UNICODE_SUPPORT 1
226 # endif
227 #else
228 # define OGRE_UNICODE_SUPPORT 1
229 #endif
230 
231 #endif // OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
232 
233 //----------------------------------------------------------------------------
234 // Linux/Apple/iOs/Android/NaCl Settings
235 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS || \
236  OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_NACL || OGRE_PLATFORM == OGRE_PLATFORM_FLASHCC
237 
238 // Enable GCC symbol visibility
239 # if defined( OGRE_GCC_VISIBILITY )
240 # define _OgreExport __attribute__ ((visibility("default")))
241 # define _OgrePrivate __attribute__ ((visibility("hidden")))
242 # else
243 # define _OgreExport
244 # define _OgrePrivate
245 # endif
246 
247 // A quick define to overcome different names for the same function
248 # define stricmp strcasecmp
249 
250 # ifdef DEBUG
251 # define OGRE_DEBUG_MODE 1
252 # else
253 # define OGRE_DEBUG_MODE 0
254 # endif
255 
256 // Always enable unicode support for the moment
257 // Perhaps disable in old versions of gcc if necessary
258 #define OGRE_UNICODE_SUPPORT 1
259 
260 #endif
261 
262 //----------------------------------------------------------------------------
263 // Android Settings
264 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
265 # ifdef OGRE_UNICODE_SUPPORT
266 # undef OGRE_UNICODE_SUPPORT
267 # endif
268 # define OGRE_UNICODE_SUPPORT 1
269 # define CLOCKS_PER_SEC 1000
270  // A quick define to overcome different names for the same function
271 # define stricmp strcasecmp
272 # ifdef DEBUG
273 # define OGRE_DEBUG_MODE 1
274 # else
275 # define OGRE_DEBUG_MODE 0
276 # endif
277 #endif
278 
279 //----------------------------------------------------------------------------
280 // FlashCC Settings
281 #if OGRE_PLATFORM == OGRE_PLATFORM_FLASHCC
282 # ifdef OGRE_UNICODE_SUPPORT
283 # undef OGRE_UNICODE_SUPPORT
284 # endif
285 # define OGRE_UNICODE_SUPPORT 0
286 # ifdef DEBUG
287 # define OGRE_DEBUG_MODE 1
288 # else
289 # define OGRE_DEBUG_MODE 0
290 # endif
291 #endif
292 
293 //----------------------------------------------------------------------------
294 // Endian Settings
295 // check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly
296 #ifdef OGRE_CONFIG_BIG_ENDIAN
297 # define OGRE_ENDIAN OGRE_ENDIAN_BIG
298 #else
299 # define OGRE_ENDIAN OGRE_ENDIAN_LITTLE
300 #endif
301 
302 //----------------------------------------------------------------------------
303 // Set the default locale for strings
304 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
305 // Locales are not supported by the C lib you have to go through JNI.
306 # define OGRE_DEFAULT_LOCALE ""
307 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
308 # define OGRE_DEFAULT_LOCALE "C"
309 #else
310 # if OGRE_COMPILER == OGRE_COMPILER_MSVC
311 # if _MSC_VER >= 1700
312 # define OGRE_DEFAULT_LOCALE "en-GB"
313 # else
314 // http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx
315 # define OGRE_DEFAULT_LOCALE "uk"
316 # endif
317 # elif OGRE_COMPILER == OGRE_COMPILER_GCCE
318 // http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
319 # define OGRE_DEFAULT_LOCALE "en_GB.UTF8"
320 # else
321 # if OGRE_NO_LIBCPP_SUPPORT == 0
322 # define OGRE_DEFAULT_LOCALE "en_GB.UTF-8"
323 # else
324 # define OGRE_DEFAULT_LOCALE "C"
325 # endif
326 # endif
327 #endif
328 
329 //----------------------------------------------------------------------------
330 // Library suffixes
331 // "_d" for debug builds, nothing otherwise
332 #if OGRE_DEBUG_MODE
333 # define OGRE_BUILD_SUFFIX "_d"
334 #else
335 # define OGRE_BUILD_SUFFIX ""
336 #endif
337 
338 // Integer formats of fixed bit width
339 typedef unsigned int uint32;
340 typedef unsigned short uint16;
341 typedef unsigned char uint8;
342 typedef int int32;
343 typedef short int16;
344 typedef signed char int8;
345 // define uint64 type
346 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
347  typedef unsigned __int64 uint64;
348  typedef __int64 int64;
349 #else
350  typedef unsigned long long uint64;
351  typedef long long int64;
352 #endif
353 
354 // Disable these warnings (too much noise)
355 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
356 # define _CRT_SECURE_NO_WARNINGS
357 # define _SCL_SECURE_NO_WARNINGS
358 // Turn off warnings generated by long std templates
359 // This warns about truncation to 255 characters in debug/browse info
360 # pragma warning (disable : 4786)
361 // Turn off warnings generated by long std templates
362 // This warns about truncation to 255 characters in debug/browse info
363 # pragma warning (disable : 4503)
364 // disable: "<type> needs to have dll-interface to be used by clients'
365 // Happens on STL member variables which are not public therefore is ok
366 # pragma warning (disable : 4251)
367 // disable: "non dll-interface class used as base for dll-interface class"
368 // Happens when deriving from Singleton because bug in compiler ignores
369 // template export
370 # pragma warning (disable : 4275)
371 // disable: "C++ Exception Specification ignored"
372 // This is because MSVC 6 did not implement all the C++ exception
373 // specifications in the ANSI C++ draft.
374 # pragma warning( disable : 4290 )
375 // disable: "no suitable definition provided for explicit template
376 // instantiation request" Occurs in VC7 for no justifiable reason on all
377 // #includes of Singleton
378 # pragma warning( disable: 4661)
379 // disable: deprecation warnings when using CRT calls in VC8
380 // These show up on all C runtime lib code in VC8, disable since they clutter
381 // the warnings with things we may not be able to do anything about (e.g.
382 // generated code from nvparse etc). I doubt very much that these calls
383 // will ever be actually removed from VC anyway, it would break too much code.
384 # pragma warning( disable: 4996)
385 // disable: "conditional expression constant", always occurs on
386 // OGRE_MUTEX_CONDITIONAL when no threading enabled
387 # pragma warning (disable : 201)
388 // disable: "unreferenced formal parameter"
389 // Many versions of VC have bugs which generate this error in cases where they shouldn't
390 # pragma warning (disable : 4100)
391 // disable: "behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized"
392 // We have this issue in OgreMemorySTLAlloc.h - so we see it over and over
393 # pragma warning (disable : 4345)
394 #endif
395 
396 }
397 
398 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:43