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-2009 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_SYMBIAN 4
00040 #define OGRE_PLATFORM_IPHONE 5
00041 
00042 #define OGRE_COMPILER_MSVC 1
00043 #define OGRE_COMPILER_GNUC 2
00044 #define OGRE_COMPILER_BORL 3
00045 #define OGRE_COMPILER_WINSCW 4
00046 #define OGRE_COMPILER_GCCE 5
00047 
00048 #define OGRE_ENDIAN_LITTLE 1
00049 #define OGRE_ENDIAN_BIG 2
00050 
00051 #define OGRE_ARCHITECTURE_32 1
00052 #define OGRE_ARCHITECTURE_64 2
00053 
00054 /* Finds the compiler type and version.
00055 */
00056 #if defined( __GCCE__ )
00057 #   define OGRE_COMPILER OGRE_COMPILER_GCCE
00058 #   define OGRE_COMP_VER _MSC_VER
00059 //# include <staticlibinit_gcce.h> // This is a GCCE toolchain workaround needed when compiling with GCCE 
00060 #elif defined( __WINSCW__ )
00061 #   define OGRE_COMPILER OGRE_COMPILER_WINSCW
00062 #   define OGRE_COMP_VER _MSC_VER
00063 #elif defined( _MSC_VER )
00064 #   define OGRE_COMPILER OGRE_COMPILER_MSVC
00065 #   define OGRE_COMP_VER _MSC_VER
00066 #elif defined( __GNUC__ )
00067 #   define OGRE_COMPILER OGRE_COMPILER_GNUC
00068 #   define OGRE_COMP_VER (((__GNUC__)*100) + \
00069         (__GNUC_MINOR__*10) + \
00070         __GNUC_PATCHLEVEL__)
00071 
00072 #elif defined( __BORLANDC__ )
00073 #   define OGRE_COMPILER OGRE_COMPILER_BORL
00074 #   define OGRE_COMP_VER __BCPLUSPLUS__
00075 #   define __FUNCTION__ __FUNC__ 
00076 #else
00077 #   pragma error "No known compiler. Abort! Abort!"
00078 
00079 #endif
00080 
00081 /* See if we can use __forceinline or if we need to use __inline instead */
00082 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00083 #   if OGRE_COMP_VER >= 1200
00084 #       define FORCEINLINE __forceinline
00085 #   endif
00086 #elif defined(__MINGW32__)
00087 #   if !defined(FORCEINLINE)
00088 #       define FORCEINLINE __inline
00089 #   endif
00090 #else
00091 #   define FORCEINLINE __inline
00092 #endif
00093 
00094 /* Finds the current platform */
00095 
00096 #if defined( __SYMBIAN32__ ) 
00097 #   define OGRE_PLATFORM OGRE_PLATFORM_SYMBIAN
00098 #elif defined( __WIN32__ ) || defined( _WIN32 )
00099 #   define OGRE_PLATFORM OGRE_PLATFORM_WIN32
00100 #elif defined( __APPLE_CC__)
00101     // Device                                                     Simulator
00102     // Both requiring OS version 3.0 or greater
00103 #   if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
00104 #       define OGRE_PLATFORM OGRE_PLATFORM_IPHONE
00105 #   else
00106 #       define OGRE_PLATFORM OGRE_PLATFORM_APPLE
00107 #   endif
00108 #else
00109 #   define OGRE_PLATFORM OGRE_PLATFORM_LINUX
00110 #endif
00111 
00112     /* Find the arch type */
00113 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
00114 #   define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64
00115 #else
00116 #   define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32
00117 #endif
00118 
00119 // For generating compiler warnings - should work on any compiler
00120 // As a side note, if you start your message with 'Warning: ', the MSVC
00121 // IDE actually does catch a warning :)
00122 #define OGRE_QUOTE_INPLACE(x) # x
00123 #define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x)
00124 #define OGRE_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
00125 
00126 //----------------------------------------------------------------------------
00127 // Windows Settings
00128 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
00129 
00130 // If we're not including this from a client build, specify that the stuff
00131 // should get exported. Otherwise, import it.
00132 #   if defined( OGRE_STATIC_LIB )
00133         // Linux compilers don't have symbol import/export directives.
00134 #       define _OgreExport
00135 #       define _OgrePrivate
00136 #   else
00137 #       if defined( OGRE_NONCLIENT_BUILD )
00138 #           define _OgreExport __declspec( dllexport )
00139 #       else
00140 #           if defined( __MINGW32__ )
00141 #               define _OgreExport
00142 #           else
00143 #               define _OgreExport __declspec( dllimport )
00144 #           endif
00145 #       endif
00146 #       define _OgrePrivate
00147 #   endif
00148 // Win32 compilers use _DEBUG for specifying debug builds.
00149 #   ifdef _DEBUG
00150 #       define OGRE_DEBUG_MODE 1
00151 #   else
00152 #       define OGRE_DEBUG_MODE 0
00153 #   endif
00154 
00155 // Disable unicode support on MingW at the moment, poorly supported in stdlibc++
00156 // STLPORT fixes this though so allow if found
00157 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h
00158 #if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION)
00159 #   include<_mingw.h>
00160 #   if defined(__MINGW32_TOOLBOX_UNICODE__)
00161 #       define OGRE_UNICODE_SUPPORT 1
00162 #   else
00163 #       define OGRE_UNICODE_SUPPORT 0
00164 #   endif
00165 #else
00166 #   define OGRE_UNICODE_SUPPORT 1
00167 #endif
00168 
00169 #endif
00170 //----------------------------------------------------------------------------
00171 // Symbian Settings
00172 #if OGRE_PLATFORM == OGRE_PLATFORM_SYMBIAN
00173 #   define OGRE_UNICODE_SUPPORT 1
00174 #   define OGRE_DEBUG_MODE 0
00175 #   define _OgreExport
00176 #   define _OgrePrivate
00177 #   define CLOCKS_PER_SEC  1000
00178 // 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
00179 #   pragma warn_unusedarg off
00180 #   pragma warn_emptydecl off
00181 #   pragma warn_possunwant off
00182 #endif
00183 //----------------------------------------------------------------------------
00184 // Linux/Apple Settings
00185 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_IPHONE
00186 
00187 // Enable GCC symbol visibility
00188 #   if defined( OGRE_GCC_VISIBILITY )
00189 #       define _OgreExport  __attribute__ ((visibility("default")))
00190 #       define _OgrePrivate __attribute__ ((visibility("hidden")))
00191 #   else
00192 #       define _OgreExport
00193 #       define _OgrePrivate
00194 #   endif
00195 
00196 // A quick define to overcome different names for the same function
00197 #   define stricmp strcasecmp
00198 
00199 // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
00200 // specifying a debug build.
00201 // (??? this is wrong, on Linux debug builds aren't marked in any way unless
00202 // you mark it yourself any way you like it -- zap ???)
00203 #   ifdef DEBUG
00204 #       define OGRE_DEBUG_MODE 1
00205 #   else
00206 #       define OGRE_DEBUG_MODE 0
00207 #   endif
00208 
00209 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
00210     #define OGRE_PLATFORM_LIB "OgrePlatform.bundle"
00211 #elif OGRE_PLATFORM == OGRE_PLATFORM_IPHONE
00212     #define OGRE_PLATFORM_LIB "OgrePlatform.a"
00213 #else //OGRE_PLATFORM_LINUX
00214     #define OGRE_PLATFORM_LIB "libOgrePlatform.so"
00215 #endif
00216 
00217 // Always enable unicode support for the moment
00218 // Perhaps disable in old versions of gcc if necessary
00219 #define OGRE_UNICODE_SUPPORT 1
00220 
00221 #endif
00222 
00223 //For apple, we always have a custom config.h file
00224 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
00225 #    include "config.h"
00226 #endif
00227 
00228 //----------------------------------------------------------------------------
00229 
00230 //----------------------------------------------------------------------------
00231 // Endian Settings
00232 // check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly
00233 #ifdef OGRE_CONFIG_BIG_ENDIAN
00234 #    define OGRE_ENDIAN OGRE_ENDIAN_BIG
00235 #else
00236 #    define OGRE_ENDIAN OGRE_ENDIAN_LITTLE
00237 #endif
00238 
00239 // Integer formats of fixed bit width
00240 typedef unsigned int uint32;
00241 typedef unsigned short uint16;
00242 typedef unsigned char uint8;
00243 typedef int int32;
00244 typedef short int16;
00245 typedef char int8;
00246 // define uint64 type
00247 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00248     typedef unsigned __int64 uint64;
00249     typedef __int64 int64;
00250 #else
00251     typedef unsigned long long uint64;
00252     typedef long long int64;
00253 #endif
00254 
00255 
00256 }
00257 
00258 #endif

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Dec 31 16:27:12 2009