OGRE  1.8
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-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 
43 #define OGRE_COMPILER_MSVC 1
44 #define OGRE_COMPILER_GNUC 2
45 #define OGRE_COMPILER_BORL 3
46 #define OGRE_COMPILER_WINSCW 4
47 #define OGRE_COMPILER_GCCE 5
48 #define OGRE_COMPILER_CLANG 6
49 
50 #define OGRE_ENDIAN_LITTLE 1
51 #define OGRE_ENDIAN_BIG 2
52 
53 #define OGRE_ARCHITECTURE_32 1
54 #define OGRE_ARCHITECTURE_64 2
55 
56 /* Finds the compiler type and version.
57 */
58 #if defined( __GCCE__ )
59 # define OGRE_COMPILER OGRE_COMPILER_GCCE
60 # define OGRE_COMP_VER _MSC_VER
61 //# include <staticlibinit_gcce.h> // This is a GCCE toolchain workaround needed when compiling with GCCE
62 #elif defined( __WINSCW__ )
63 # define OGRE_COMPILER OGRE_COMPILER_WINSCW
64 # define OGRE_COMP_VER _MSC_VER
65 #elif defined( _MSC_VER )
66 # define OGRE_COMPILER OGRE_COMPILER_MSVC
67 # define OGRE_COMP_VER _MSC_VER
68 #elif defined( __clang__ )
69 # define OGRE_COMPILER OGRE_COMPILER_CLANG
70 # define OGRE_COMP_VER (((__clang_major__)*100) + \
71  (__clang_minor__*10) + \
72  __clang_patchlevel__)
73 #elif defined( __GNUC__ )
74 # define OGRE_COMPILER OGRE_COMPILER_GNUC
75 # define OGRE_COMP_VER (((__GNUC__)*100) + \
76  (__GNUC_MINOR__*10) + \
77  __GNUC_PATCHLEVEL__)
78 #elif defined( __BORLANDC__ )
79 # define OGRE_COMPILER OGRE_COMPILER_BORL
80 # define OGRE_COMP_VER __BCPLUSPLUS__
81 # define __FUNCTION__ __FUNC__
82 #else
83 # pragma error "No known compiler. Abort! Abort!"
84 
85 #endif
86 
87 /* See if we can use __forceinline or if we need to use __inline instead */
88 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
89 # if OGRE_COMP_VER >= 1200
90 # define FORCEINLINE __forceinline
91 # endif
92 #elif defined(__MINGW32__)
93 # if !defined(FORCEINLINE)
94 # define FORCEINLINE __inline
95 # endif
96 #else
97 # define FORCEINLINE __inline
98 #endif
99 
100 /* Finds the current platform */
101 
102 #if defined( __WIN32__ ) || defined( _WIN32 )
103 # define OGRE_PLATFORM OGRE_PLATFORM_WIN32
104 #elif defined( __APPLE_CC__)
105  // Device Simulator
106  // Both requiring OS version 4.0 or greater
107 # if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
108 # define OGRE_PLATFORM OGRE_PLATFORM_APPLE_IOS
109 # else
110 # define OGRE_PLATFORM OGRE_PLATFORM_APPLE
111 # endif
112 #elif defined(__ANDROID__)
113 # define OGRE_PLATFORM OGRE_PLATFORM_ANDROID
114 #elif defined( __native_client__ )
115 # define OGRE_PLATFORM OGRE_PLATFORM_NACL
116 # ifndef OGRE_STATIC_LIB
117 # error OGRE must be built as static for NaCl (OGRE_STATIC=true in CMake)
118 # endif
119 # ifdef OGRE_BUILD_RENDERSYSTEM_D3D9
120 # error D3D9 is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_D3D9 false in CMake)
121 # endif
122 # ifdef OGRE_BUILD_RENDERSYSTEM_GL
123 # error OpenGL is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_GL=false in CMake)
124 # endif
125 # ifndef OGRE_BUILD_RENDERSYSTEM_GLES2
126 # error GLES2 render system is required for NaCl (OGRE_BUILD_RENDERSYSTEM_GLES2=false in CMake)
127 # endif
128 #else
129 # define OGRE_PLATFORM OGRE_PLATFORM_LINUX
130 #endif
131 
132  /* Find the arch type */
133 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
134 # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64
135 #else
136 # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32
137 #endif
138 
139 // For generating compiler warnings - should work on any compiler
140 // As a side note, if you start your message with 'Warning: ', the MSVC
141 // IDE actually does catch a warning :)
142 #define OGRE_QUOTE_INPLACE(x) # x
143 #define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x)
144 #define OGRE_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
145 
146 //----------------------------------------------------------------------------
147 // Windows Settings
148 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
149 
150 // If we're not including this from a client build, specify that the stuff
151 // should get exported. Otherwise, import it.
152 # if defined( OGRE_STATIC_LIB )
153  // Linux compilers don't have symbol import/export directives.
154 # define _OgreExport
155 # define _OgrePrivate
156 # else
157 # if defined( OGRE_NONCLIENT_BUILD )
158 # define _OgreExport __declspec( dllexport )
159 # else
160 # if defined( __MINGW32__ )
161 # define _OgreExport
162 # else
163 # define _OgreExport __declspec( dllimport )
164 # endif
165 # endif
166 # define _OgrePrivate
167 # endif
168 // Win32 compilers use _DEBUG for specifying debug builds.
169 // for MinGW, we set DEBUG
170 # if defined(_DEBUG) || defined(DEBUG)
171 # define OGRE_DEBUG_MODE 1
172 # else
173 # define OGRE_DEBUG_MODE 0
174 # endif
175 
176 // Disable unicode support on MingW for GCC 3, poorly supported in stdlibc++
177 // STLPORT fixes this though so allow if found
178 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLBOX_UNICODE__ in _mingw.h
179 // GCC 4 is also fine
180 #if defined(__MINGW32__)
181 # if OGRE_COMP_VER < 400
182 # if !defined(_STLPORT_VERSION)
183 # include<_mingw.h>
184 # if defined(__MINGW32_TOOLBOX_UNICODE__) || OGRE_COMP_VER > 345
185 # define OGRE_UNICODE_SUPPORT 1
186 # else
187 # define OGRE_UNICODE_SUPPORT 0
188 # endif
189 # else
190 # define OGRE_UNICODE_SUPPORT 1
191 # endif
192 # else
193 # define OGRE_UNICODE_SUPPORT 1
194 # endif
195 #else
196 # define OGRE_UNICODE_SUPPORT 1
197 #endif
198 
199 #endif // OGRE_PLATFORM == OGRE_PLATFORM_WIN32
200 
201 //----------------------------------------------------------------------------
202 // Android Settings
203 /*
204 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
205 # define _OgreExport
206 # define OGRE_UNICODE_SUPPORT 1
207 # define OGRE_DEBUG_MODE 0
208 # define _OgrePrivate
209 # define CLOCKS_PER_SEC 1000
210 // pragma def were found here: http://www.inf.pucrs.br/~eduardob/disciplinas/SistEmbarcados/Mobile/Nokia/Tools/Carbide_vs/WINSCW/Help/PDF/C_Compilers_Reference_3.2.pdf
211 # pragma warn_unusedarg off
212 # pragma warn_emptydecl off
213 # pragma warn_possunwant off
214 // A quick define to overcome different names for the same function
215 # define stricmp strcasecmp
216 # ifdef DEBUG
217 # define OGRE_DEBUG_MODE 1
218 # else
219 # define OGRE_DEBUG_MODE 0
220 # endif
221 #endif
222 */
223 //----------------------------------------------------------------------------
224 // Linux/Apple/iOs/Android/NaCl Settings
225 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS || \
226  OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_NACL
227 
228 // Enable GCC symbol visibility
229 # if defined( OGRE_GCC_VISIBILITY )
230 # define _OgreExport __attribute__ ((visibility("default")))
231 # define _OgrePrivate __attribute__ ((visibility("hidden")))
232 # else
233 # define _OgreExport
234 # define _OgrePrivate
235 # endif
236 
237 // A quick define to overcome different names for the same function
238 # define stricmp strcasecmp
239 
240 # ifdef DEBUG
241 # define OGRE_DEBUG_MODE 1
242 # else
243 # define OGRE_DEBUG_MODE 0
244 # endif
245 
246 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
247  #define OGRE_PLATFORM_LIB "OgrePlatform.bundle"
248 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
249  #define OGRE_PLATFORM_LIB "OgrePlatform.a"
250 #else //OGRE_PLATFORM_LINUX
251  #define OGRE_PLATFORM_LIB "libOgrePlatform.so"
252 #endif
253 
254 // Always enable unicode support for the moment
255 // Perhaps disable in old versions of gcc if necessary
256 #define OGRE_UNICODE_SUPPORT 1
257 
258 #endif
259 
260 //----------------------------------------------------------------------------
261 // Endian Settings
262 // check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly
263 #ifdef OGRE_CONFIG_BIG_ENDIAN
264 # define OGRE_ENDIAN OGRE_ENDIAN_BIG
265 #else
266 # define OGRE_ENDIAN OGRE_ENDIAN_LITTLE
267 #endif
268 
269 // Integer formats of fixed bit width
270 typedef unsigned int uint32;
271 typedef unsigned short uint16;
272 typedef unsigned char uint8;
273 typedef int int32;
274 typedef short int16;
275 typedef char int8;
276 // define uint64 type
277 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
278  typedef unsigned __int64 uint64;
279  typedef __int64 int64;
280 #else
281  typedef unsigned long long uint64;
282  typedef long long int64;
283 #endif
284 
285 
286 }
287 
288 #endif
unsigned char uint8
Definition: OgrePlatform.h:272
unsigned int uint32
Definition: OgrePlatform.h:270
long long int64
Definition: OgrePlatform.h:282
char int8
Definition: OgrePlatform.h:275
short int16
Definition: OgrePlatform.h:274
unsigned long long uint64
Definition: OgrePlatform.h:281
int int32
Definition: OgrePlatform.h:273
unsigned short uint16
Definition: OgrePlatform.h:271