OgrePlatform.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __Platform_H_
  25. #define __Platform_H_
  26. #include "OgreConfig.h"
  27. namespace Ogre {
  28. /* Initial platform/compiler-related stuff to set.
  29. */
  30. #define OGRE_PLATFORM_WIN32 1
  31. #define OGRE_PLATFORM_LINUX 2
  32. #define OGRE_PLATFORM_APPLE 3
  33. #define OGRE_PLATFORM_SYMBIAN 4
  34. #define OGRE_PLATFORM_IPHONE 5
  35. #define OGRE_COMPILER_MSVC 1
  36. #define OGRE_COMPILER_GNUC 2
  37. #define OGRE_COMPILER_BORL 3
  38. #define OGRE_COMPILER_WINSCW 4
  39. #define OGRE_COMPILER_GCCE 5
  40. #define OGRE_ENDIAN_LITTLE 1
  41. #define OGRE_ENDIAN_BIG 2
  42. #define OGRE_ARCHITECTURE_32 1
  43. #define OGRE_ARCHITECTURE_64 2
  44. /* Finds the compiler type and version.
  45. */
  46. #if defined( __GCCE__ )
  47. # define OGRE_COMPILER OGRE_COMPILER_GCCE
  48. # define OGRE_COMP_VER _MSC_VER
  49. //# include <staticlibinit_gcce.h> // This is a GCCE toolchain workaround needed when compiling with GCCE
  50. #elif defined( __WINSCW__ )
  51. # define OGRE_COMPILER OGRE_COMPILER_WINSCW
  52. # define OGRE_COMP_VER _MSC_VER
  53. #elif defined( _MSC_VER )
  54. # define OGRE_COMPILER OGRE_COMPILER_MSVC
  55. # define OGRE_COMP_VER _MSC_VER
  56. #elif defined( __GNUC__ )
  57. # define OGRE_COMPILER OGRE_COMPILER_GNUC
  58. # define OGRE_COMP_VER (((__GNUC__)*100) + \
  59. (__GNUC_MINOR__*10) + \
  60. __GNUC_PATCHLEVEL__)
  61. #elif defined( __BORLANDC__ )
  62. # define OGRE_COMPILER OGRE_COMPILER_BORL
  63. # define OGRE_COMP_VER __BCPLUSPLUS__
  64. # define __FUNCTION__ __FUNC__
  65. #else
  66. # pragma error "No known compiler. Abort! Abort!"
  67. #endif
  68. /* See if we can use __forceinline or if we need to use __inline instead */
  69. #if OGRE_COMPILER == OGRE_COMPILER_MSVC
  70. # if OGRE_COMP_VER >= 1200
  71. # define FORCEINLINE __forceinline
  72. # endif
  73. #elif defined(__MINGW32__)
  74. # if !defined(FORCEINLINE)
  75. # define FORCEINLINE __inline
  76. # endif
  77. #else
  78. # define FORCEINLINE __inline
  79. #endif
  80. /* Finds the current platform */
  81. #if defined( __SYMBIAN32__ )
  82. # define OGRE_PLATFORM OGRE_PLATFORM_SYMBIAN
  83. #elif defined( __WIN32__ ) || defined( _WIN32 )
  84. # define OGRE_PLATFORM OGRE_PLATFORM_WIN32
  85. #elif defined( __APPLE_CC__)
  86. // Device Simulator
  87. // Both requiring OS version 3.0 or greater
  88. # if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
  89. # define OGRE_PLATFORM OGRE_PLATFORM_IPHONE
  90. # else
  91. # define OGRE_PLATFORM OGRE_PLATFORM_APPLE
  92. # endif
  93. #else
  94. # define OGRE_PLATFORM OGRE_PLATFORM_LINUX
  95. #endif
  96. /* Find the arch type */
  97. #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
  98. # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64
  99. #else
  100. # define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32
  101. #endif
  102. // For generating compiler warnings - should work on any compiler
  103. // As a side note, if you start your message with 'Warning: ', the MSVC
  104. // IDE actually does catch a warning :)
  105. #define OGRE_QUOTE_INPLACE(x) # x
  106. #define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x)
  107. #define OGRE_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
  108. //----------------------------------------------------------------------------
  109. // Windows Settings
  110. #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
  111. // If we're not including this from a client build, specify that the stuff
  112. // should get exported. Otherwise, import it.
  113. # if defined( OGRE_STATIC_LIB )
  114. // Linux compilers don't have symbol import/export directives.
  115. # define _OgreExport
  116. # define _OgrePrivate
  117. # else
  118. # if defined( OGRE_NONCLIENT_BUILD )
  119. # define _OgreExport __declspec( dllexport )
  120. # else
  121. # if defined( __MINGW32__ )
  122. # define _OgreExport
  123. # else
  124. # define _OgreExport __declspec( dllimport )
  125. # endif
  126. # endif
  127. # define _OgrePrivate
  128. # endif
  129. // Win32 compilers use _DEBUG for specifying debug builds.
  130. // for MinGW, we set DEBUG
  131. # if defined(_DEBUG) || defined(DEBUG)
  132. # define OGRE_DEBUG_MODE 1
  133. # else
  134. # define OGRE_DEBUG_MODE 0
  135. # endif
  136. // Disable unicode support on MingW for GCC 3, poorly supported in stdlibc++
  137. // STLPORT fixes this though so allow if found
  138. // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLBOX_UNICODE__ in _mingw.h
  139. // GCC 4 is also fine
  140. #if defined(__MINGW32__)
  141. # if OGRE_COMP_VER < 400
  142. # if !defined(_STLPORT_VERSION)
  143. # include<_mingw.h>
  144. # if defined(__MINGW32_TOOLBOX_UNICODE__) || OGRE_COMP_VER > 345
  145. # define OGRE_UNICODE_SUPPORT 1
  146. # else
  147. # define OGRE_UNICODE_SUPPORT 0
  148. # endif
  149. # else
  150. # define OGRE_UNICODE_SUPPORT 1
  151. # endif
  152. # else
  153. # define OGRE_UNICODE_SUPPORT 1
  154. # endif
  155. #else
  156. # define OGRE_UNICODE_SUPPORT 1
  157. #endif
  158. #endif // OGRE_PLATFORM == OGRE_PLATFORM_WIN32
  159. //----------------------------------------------------------------------------
  160. // Symbian Settings
  161. #if OGRE_PLATFORM == OGRE_PLATFORM_SYMBIAN
  162. # define OGRE_UNICODE_SUPPORT 1
  163. # define OGRE_DEBUG_MODE 0
  164. # define _OgreExport
  165. # define _OgrePrivate
  166. # define CLOCKS_PER_SEC 1000
  167. // 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
  168. # pragma warn_unusedarg off
  169. # pragma warn_emptydecl off
  170. # pragma warn_possunwant off
  171. #endif
  172. //----------------------------------------------------------------------------
  173. // Linux/Apple/Symbian Settings
  174. #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_IPHONE || OGRE_PLATFORM == OGRE_PLATFORM_SYMBIAN
  175. // Enable GCC symbol visibility
  176. # if defined( OGRE_GCC_VISIBILITY )
  177. # define _OgreExport __attribute__ ((visibility("default")))
  178. # define _OgrePrivate __attribute__ ((visibility("hidden")))
  179. # else
  180. # define _OgreExport
  181. # define _OgrePrivate
  182. # endif
  183. // A quick define to overcome different names for the same function
  184. # define stricmp strcasecmp
  185. // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
  186. // specifying a debug build.
  187. // (??? this is wrong, on Linux debug builds aren't marked in any way unless
  188. // you mark it yourself any way you like it -- zap ???)
  189. # ifdef DEBUG
  190. # define OGRE_DEBUG_MODE 1
  191. # else
  192. # define OGRE_DEBUG_MODE 0
  193. # endif
  194. #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
  195. #define OGRE_PLATFORM_LIB "OgrePlatform.bundle"
  196. #elif OGRE_PLATFORM == OGRE_PLATFORM_IPHONE
  197. #define OGRE_PLATFORM_LIB "OgrePlatform.a"
  198. #else //OGRE_PLATFORM_LINUX
  199. #define OGRE_PLATFORM_LIB "libOgrePlatform.so"
  200. #endif
  201. // Always enable unicode support for the moment
  202. // Perhaps disable in old versions of gcc if necessary
  203. #define OGRE_UNICODE_SUPPORT 1
  204. #endif
  205. //----------------------------------------------------------------------------
  206. //----------------------------------------------------------------------------
  207. // Endian Settings
  208. // check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly
  209. #ifdef OGRE_CONFIG_BIG_ENDIAN
  210. # define OGRE_ENDIAN OGRE_ENDIAN_BIG
  211. #else
  212. # define OGRE_ENDIAN OGRE_ENDIAN_LITTLE
  213. #endif
  214. // Integer formats of fixed bit width
  215. typedef unsigned int uint32;
  216. typedef unsigned short uint16;
  217. typedef unsigned char uint8;
  218. typedef int int32;
  219. typedef short int16;
  220. typedef char int8;
  221. // define uint64 type
  222. #if OGRE_COMPILER == OGRE_COMPILER_MSVC
  223. typedef unsigned __int64 uint64;
  224. typedef __int64 int64;
  225. #else
  226. typedef unsigned long long uint64;
  227. typedef long long int64;
  228. #endif
  229. }
  230. #endif