OgrePlatform.h
Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2013 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef __Platform_H_
00029 #define __Platform_H_
00030 
00031 #include "OgreConfig.h"
00032 
00033 namespace Ogre {
00034 /* Initial platform/compiler-related stuff to set.
00035 */
00036 #define OGRE_PLATFORM_WIN32 1
00037 #define OGRE_PLATFORM_LINUX 2
00038 #define OGRE_PLATFORM_APPLE 3
00039 #define OGRE_PLATFORM_APPLE_IOS 4
00040 #define OGRE_PLATFORM_ANDROID 5
00041 #define OGRE_PLATFORM_NACL 6
00042 #define OGRE_PLATFORM_WINRT 7
00043 #define OGRE_PLATFORM_FLASHCC 8
00044 
00045 #define OGRE_COMPILER_MSVC 1
00046 #define OGRE_COMPILER_GNUC 2
00047 #define OGRE_COMPILER_BORL 3
00048 #define OGRE_COMPILER_WINSCW 4
00049 #define OGRE_COMPILER_GCCE 5
00050 #define OGRE_COMPILER_CLANG 6
00051 
00052 #define OGRE_ENDIAN_LITTLE 1
00053 #define OGRE_ENDIAN_BIG 2
00054 
00055 #define OGRE_ARCHITECTURE_32 1
00056 #define OGRE_ARCHITECTURE_64 2
00057 
00058 /* Finds the compiler type and version.
00059 */
00060 #if (defined( __WIN32__ ) || defined( _WIN32 )) && defined(__ANDROID__) // We are using NVTegra
00061 #   define OGRE_COMPILER OGRE_COMPILER_GNUC
00062 #   define OGRE_COMP_VER 470
00063 #elif defined( __GCCE__ )
00064 #   define OGRE_COMPILER OGRE_COMPILER_GCCE
00065 #   define OGRE_COMP_VER _MSC_VER
00066 //# include <staticlibinit_gcce.h> // This is a GCCE toolchain workaround needed when compiling with GCCE 
00067 #elif defined( __WINSCW__ )
00068 #   define OGRE_COMPILER OGRE_COMPILER_WINSCW
00069 #   define OGRE_COMP_VER _MSC_VER
00070 #elif defined( _MSC_VER )
00071 #   define OGRE_COMPILER OGRE_COMPILER_MSVC
00072 #   define OGRE_COMP_VER _MSC_VER
00073 #elif defined( __clang__ )
00074 #   define OGRE_COMPILER OGRE_COMPILER_CLANG
00075 #   define OGRE_COMP_VER (((__clang_major__)*100) + \
00076         (__clang_minor__*10) + \
00077         __clang_patchlevel__)
00078 #elif defined( __GNUC__ )
00079 #   define OGRE_COMPILER OGRE_COMPILER_GNUC
00080 #   define OGRE_COMP_VER (((__GNUC__)*100) + \
00081         (__GNUC_MINOR__*10) + \
00082         __GNUC_PATCHLEVEL__)
00083 #elif defined( __BORLANDC__ )
00084 #   define OGRE_COMPILER OGRE_COMPILER_BORL
00085 #   define OGRE_COMP_VER __BCPLUSPLUS__
00086 #   define __FUNCTION__ __FUNC__ 
00087 #else
00088 #   pragma error "No known compiler. Abort! Abort!"
00089 
00090 #endif
00091 
00092 /* See if we can use __forceinline or if we need to use __inline instead */
00093 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00094 #   if OGRE_COMP_VER >= 1200
00095 #       define FORCEINLINE __forceinline
00096 #   endif
00097 #elif defined(__MINGW32__)
00098 #   if !defined(FORCEINLINE)
00099 #       define FORCEINLINE __inline
00100 #   endif
00101 #else
00102 #   define FORCEINLINE __inline
00103 #endif
00104 
00105 /* Finds the current platform */
00106 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(__ANDROID__)
00107 #   if defined(WINAPI_FAMILY)
00108 #       define __OGRE_HAVE_DIRECTXMATH 1
00109 #       include <winapifamily.h>
00110 #       if WINAPI_FAMILY == WINAPI_FAMILY_APP|| WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
00111 #           define DESKTOP_APP 1
00112 #           define PHONE 2
00113 #           define OGRE_PLATFORM OGRE_PLATFORM_WINRT
00114 #           ifndef _CRT_SECURE_NO_WARNINGS
00115 #               define _CRT_SECURE_NO_WARNINGS
00116 #           endif
00117 #           ifndef _SCL_SECURE_NO_WARNINGS
00118 #               define _SCL_SECURE_NO_WARNINGS
00119 #           endif
00120 #           if WINAPI_FAMILY == WINAPI_FAMILY_APP
00121 #               define OGRE_WINRT_TARGET_TYPE DESKTOP_APP
00122 #           endif
00123 #           if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
00124 #               define OGRE_WINRT_TARGET_TYPE PHONE
00125 #           endif
00126 #       else
00127 #           define OGRE_PLATFORM OGRE_PLATFORM_WIN32
00128 #       endif
00129 #   else
00130 #       define OGRE_PLATFORM OGRE_PLATFORM_WIN32
00131 #   endif
00132 #elif defined(__FLASHCC__)
00133 #   define OGRE_PLATFORM OGRE_PLATFORM_FLASHCC
00134 #elif defined( __APPLE_CC__)
00135 #   ifndef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
00136 #       define __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ 0
00137 #   endif
00138 #   ifndef __IPHONE_OS_VERSION_MIN_REQUIRED
00139 #       define __IPHONE_OS_VERSION_MIN_REQUIRED 0
00140 #   endif
00141     // Device                                                     Simulator
00142     // Both requiring OS version 6.0 or greater
00143 #   if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 60000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
00144 #       define OGRE_PLATFORM OGRE_PLATFORM_APPLE_IOS
00145 #   else
00146 #       define OGRE_PLATFORM OGRE_PLATFORM_APPLE
00147 #   endif
00148 #elif defined(__ANDROID__)
00149 #   define OGRE_PLATFORM OGRE_PLATFORM_ANDROID
00150 #elif defined( __native_client__ ) 
00151 #   define OGRE_PLATFORM OGRE_PLATFORM_NACL
00152 #   ifndef OGRE_STATIC_LIB
00153 #       error OGRE must be built as static for NaCl (OGRE_STATIC=true in CMake)
00154 #   endif
00155 #   ifdef OGRE_BUILD_RENDERSYSTEM_D3D9
00156 #       error D3D9 is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_D3D9 false in CMake)
00157 #   endif
00158 #   ifdef OGRE_BUILD_RENDERSYSTEM_GL
00159 #       error OpenGL is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_GL=false in CMake)
00160 #   endif
00161 #   ifndef OGRE_BUILD_RENDERSYSTEM_GLES2
00162 #       error GLES2 render system is required for NaCl (OGRE_BUILD_RENDERSYSTEM_GLES2=false in CMake)
00163 #   endif
00164 #else
00165 #   define OGRE_PLATFORM OGRE_PLATFORM_LINUX
00166 #endif
00167 
00168     /* Find the arch type */
00169 #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_)
00170 #   define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64
00171 #else
00172 #   define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32
00173 #endif
00174 
00175 // For generating compiler warnings - should work on any compiler
00176 // As a side note, if you start your message with 'Warning: ', the MSVC
00177 // IDE actually does catch a warning :)
00178 #define OGRE_QUOTE_INPLACE(x) # x
00179 #define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x)
00180 #define OGRE_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
00181 
00182 // For marking functions as deprecated
00183 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00184 #   define OGRE_DEPRECATED __declspec(deprecated)
00185 #elif OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG
00186 #   define OGRE_DEPRECATED __attribute__ ((deprecated))
00187 #else
00188 #   pragma message("WARNING: You need to implement OGRE_DEPRECATED for this compiler")
00189 #   define OGRE_DEPRECATED
00190 #endif
00191 
00192 //----------------------------------------------------------------------------
00193 // Windows Settings
00194 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
00195 
00196 // If we're not including this from a client build, specify that the stuff
00197 // should get exported. Otherwise, import it.
00198 #   if defined( OGRE_STATIC_LIB )
00199         // Linux compilers don't have symbol import/export directives.
00200 #       define _OgreExport
00201 #       define _OgrePrivate
00202 #   else
00203 #       if defined( OGRE_NONCLIENT_BUILD )
00204 #           define _OgreExport __declspec( dllexport )
00205 #       else
00206 #           if defined( __MINGW32__ )
00207 #               define _OgreExport
00208 #           else
00209 #               define _OgreExport __declspec( dllimport )
00210 #           endif
00211 #       endif
00212 #       define _OgrePrivate
00213 #   endif
00214 // Win32 compilers use _DEBUG for specifying debug builds.
00215 // for MinGW, we set DEBUG
00216 #   if defined(_DEBUG) || defined(DEBUG)
00217 #       define OGRE_DEBUG_MODE 1
00218 #   else
00219 #       define OGRE_DEBUG_MODE 0
00220 #   endif
00221 
00222 // Disable unicode support on MingW for GCC 3, poorly supported in stdlibc++
00223 // STLPORT fixes this though so allow if found
00224 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLBOX_UNICODE__ in _mingw.h
00225 // GCC 4 is also fine
00226 #if defined(__MINGW32__)
00227 # if OGRE_COMP_VER < 400
00228 #  if !defined(_STLPORT_VERSION)
00229 #   include<_mingw.h>
00230 #   if defined(__MINGW32_TOOLBOX_UNICODE__) || OGRE_COMP_VER > 345
00231 #    define OGRE_UNICODE_SUPPORT 1
00232 #   else
00233 #    define OGRE_UNICODE_SUPPORT 0
00234 #   endif
00235 #  else
00236 #   define OGRE_UNICODE_SUPPORT 1
00237 #  endif
00238 # else
00239 #  define OGRE_UNICODE_SUPPORT 1
00240 # endif
00241 #else
00242 #  define OGRE_UNICODE_SUPPORT 1
00243 #endif
00244 
00245 #endif // OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
00246 
00247 //----------------------------------------------------------------------------
00248 // Linux/Apple/iOS/Android/NaCl Settings
00249 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS || \
00250     OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_NACL || OGRE_PLATFORM == OGRE_PLATFORM_FLASHCC
00251 
00252 // Enable GCC symbol visibility
00253 #   if defined( OGRE_GCC_VISIBILITY )
00254 #       define _OgreExport  __attribute__ ((visibility("default")))
00255 #       define _OgrePrivate __attribute__ ((visibility("hidden")))
00256 #   else
00257 #       define _OgreExport
00258 #       define _OgrePrivate
00259 #   endif
00260 
00261 // A quick define to overcome different names for the same function
00262 #   define stricmp strcasecmp
00263 
00264 #   ifdef DEBUG
00265 #       define OGRE_DEBUG_MODE 1
00266 #   else
00267 #       define OGRE_DEBUG_MODE 0
00268 #   endif
00269 
00270 // Always enable unicode support for the moment
00271 // Perhaps disable in old versions of gcc if necessary
00272 #define OGRE_UNICODE_SUPPORT 1
00273 
00274 #endif
00275 
00276 //----------------------------------------------------------------------------
00277 // Android Settings
00278 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
00279 #   ifdef OGRE_UNICODE_SUPPORT
00280 #       undef OGRE_UNICODE_SUPPORT
00281 #   endif
00282 #   define OGRE_UNICODE_SUPPORT 1
00283     // A quick define to overcome different names for the same function
00284 #   define stricmp strcasecmp
00285 #   ifdef DEBUG
00286 #       define OGRE_DEBUG_MODE 1
00287 #   else
00288 #       define OGRE_DEBUG_MODE 0
00289 #   endif
00290 #   ifndef CLOCKS_PER_SEC
00291 #       define CLOCKS_PER_SEC  1000
00292 #   endif
00293 #endif
00294     
00295 //----------------------------------------------------------------------------
00296 // FlashCC Settings
00297 #if OGRE_PLATFORM == OGRE_PLATFORM_FLASHCC
00298 #   ifdef OGRE_UNICODE_SUPPORT
00299 #       undef OGRE_UNICODE_SUPPORT
00300 #   endif
00301 #   define OGRE_UNICODE_SUPPORT 0
00302 #   ifdef DEBUG
00303 #       define OGRE_DEBUG_MODE 1
00304 #   else
00305 #       define OGRE_DEBUG_MODE 0
00306 #   endif
00307 #endif
00308 
00309 #ifndef __OGRE_HAVE_DIRECTXMATH
00310 #   define __OGRE_HAVE_DIRECTXMATH 0
00311 #endif
00312 
00313 //----------------------------------------------------------------------------
00314 // Endian Settings
00315 // check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly
00316 #ifdef OGRE_CONFIG_BIG_ENDIAN
00317 #    define OGRE_ENDIAN OGRE_ENDIAN_BIG
00318 #else
00319 #    define OGRE_ENDIAN OGRE_ENDIAN_LITTLE
00320 #endif
00321 
00322 //----------------------------------------------------------------------------
00323 // Set the default locale for strings
00324 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
00325 //  Locales are not supported by the C lib you have to go through JNI.
00326 #   define OGRE_DEFAULT_LOCALE ""
00327 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
00328 #   define OGRE_DEFAULT_LOCALE "C"
00329 #else
00330 #   if OGRE_COMPILER == OGRE_COMPILER_MSVC
00331 #       if _MSC_VER >= 1700
00332 #           define OGRE_DEFAULT_LOCALE "en-GB"
00333 #       else
00334 //          http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx
00335 #           define OGRE_DEFAULT_LOCALE "uk"
00336 #       endif
00337 #   elif OGRE_COMPILER == OGRE_COMPILER_GCCE
00338 //      http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
00339 #       define OGRE_DEFAULT_LOCALE "en_GB.UTF8"
00340 #   else
00341 #       if OGRE_NO_LIBCPP_SUPPORT == 0
00342 #           define OGRE_DEFAULT_LOCALE "en_GB.UTF-8"
00343 #       else
00344 #           define OGRE_DEFAULT_LOCALE "C"
00345 #       endif
00346 #   endif
00347 #endif
00348 
00349 //----------------------------------------------------------------------------
00350 // Library suffixes
00351 // "_d" for debug builds, nothing otherwise
00352 #if OGRE_DEBUG_MODE
00353 #   define OGRE_BUILD_SUFFIX "_d"
00354 #else
00355 #   define OGRE_BUILD_SUFFIX ""
00356 #endif
00357 
00358 // Integer formats of fixed bit width
00359 typedef unsigned int uint32;
00360 typedef unsigned short uint16;
00361 typedef unsigned char uint8;
00362 typedef int int32;
00363 typedef short int16;
00364 typedef signed char int8;
00365 // define uint64 type
00366 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00367     typedef unsigned __int64 uint64;
00368     typedef __int64 int64;
00369 #else
00370     typedef unsigned long long uint64;
00371     typedef long long int64;
00372 #endif
00373 
00374 // Disable these warnings (too much noise)
00375 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00376 #ifndef _CRT_SECURE_NO_WARNINGS
00377 #   define _CRT_SECURE_NO_WARNINGS
00378 #endif
00379 #ifndef _SCL_SECURE_NO_WARNINGS
00380 #   define _SCL_SECURE_NO_WARNINGS
00381 #endif
00382 // Turn off warnings generated by long std templates
00383 // This warns about truncation to 255 characters in debug/browse info
00384 #   pragma warning (disable : 4786)
00385 // Turn off warnings generated by long std templates
00386 // This warns about truncation to 255 characters in debug/browse info
00387 #   pragma warning (disable : 4503)
00388 // disable: "<type> needs to have dll-interface to be used by clients'
00389 // Happens on STL member variables which are not public therefore is ok
00390 #   pragma warning (disable : 4251)
00391 // disable: "non dll-interface class used as base for dll-interface class"
00392 // Happens when deriving from Singleton because bug in compiler ignores
00393 // template export
00394 #   pragma warning (disable : 4275)
00395 // disable: "C++ Exception Specification ignored"
00396 // This is because MSVC 6 did not implement all the C++ exception
00397 // specifications in the ANSI C++ draft.
00398 #   pragma warning( disable : 4290 )
00399 // disable: "no suitable definition provided for explicit template
00400 // instantiation request" Occurs in VC7 for no justifiable reason on all
00401 // #includes of Singleton
00402 #   pragma warning( disable: 4661)
00403 // disable: deprecation warnings when using CRT calls in VC8
00404 // These show up on all C runtime lib code in VC8, disable since they clutter
00405 // the warnings with things we may not be able to do anything about (e.g.
00406 // generated code from nvparse etc). I doubt very much that these calls
00407 // will ever be actually removed from VC anyway, it would break too much code.
00408 #   pragma warning( disable: 4996)
00409 // disable: "conditional expression constant", always occurs on 
00410 // OGRE_MUTEX_CONDITIONAL when no threading enabled
00411 #   pragma warning (disable : 201)
00412 // disable: "unreferenced formal parameter"
00413 // Many versions of VC have bugs which generate this error in cases where they shouldn't
00414 #   pragma warning (disable : 4100)
00415 // disable: "behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized"
00416 // We have this issue in OgreMemorySTLAlloc.h - so we see it over and over
00417 #   pragma warning (disable : 4345)
00418 #endif
00419 
00420 }
00421 
00422 #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 Mon Jul 27 2020 13:40:44