| [682] | 1 | /* | 
|---|
 | 2 |  *   ORXONOX - the hottest 3D action shooter ever to exist | 
|---|
| [1505] | 3 |  *                    > www.orxonox.net < | 
|---|
| [682] | 4 |  * | 
|---|
 | 5 |  * | 
|---|
 | 6 |  *   License notice: | 
|---|
 | 7 |  * | 
|---|
 | 8 |  *   This program is free software; you can redistribute it and/or | 
|---|
 | 9 |  *   modify it under the terms of the GNU General Public License | 
|---|
 | 10 |  *   as published by the Free Software Foundation; either version 2 | 
|---|
 | 11 |  *   of the License, or (at your option) any later version. | 
|---|
 | 12 |  * | 
|---|
 | 13 |  *   This program is distributed in the hope that it will be useful, | 
|---|
 | 14 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
 | 15 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
 | 16 |  *   GNU General Public License for more details. | 
|---|
 | 17 |  * | 
|---|
 | 18 |  *   You should have received a copy of the GNU General Public License | 
|---|
 | 19 |  *   along with this program; if not, write to the Free Software | 
|---|
 | 20 |  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
|---|
 | 21 |  * | 
|---|
 | 22 |  *   Author: | 
|---|
| [1293] | 23 |  *      ... | 
|---|
| [682] | 24 |  *   Co-authors: | 
|---|
| [1032] | 25 |  *      Reto Grieder | 
|---|
| [682] | 26 |  * | 
|---|
| [1652] | 27 |  *   Original code: OgrePlatform.h, licensed under the LGPL. The code | 
|---|
 | 28 |  *   has changed quite a bit however. | 
|---|
 | 29 |  * | 
|---|
| [682] | 30 |  */ | 
|---|
| [1505] | 31 |  | 
|---|
| [682] | 32 | /** | 
|---|
| [1032] | 33 |  @file | 
|---|
| [1652] | 34 |  @brief | 
|---|
 | 35 |     Various constants for compiler, architecture and platform. | 
|---|
| [682] | 36 |  */ | 
|---|
| [1505] | 37 |  | 
|---|
 | 38 | #ifndef _OrxonoxPlatform_H__ | 
|---|
 | 39 | #define _OrxonoxPlatform_H__ | 
|---|
 | 40 |  | 
|---|
| [1652] | 41 | /* Initial platform/compiler-related stuff to set. */ | 
|---|
 | 42 |  | 
|---|
| [1505] | 43 | #define ORXONOX_PLATFORM_WIN32 1 | 
|---|
 | 44 | #define ORXONOX_PLATFORM_LINUX 2 | 
|---|
 | 45 | #define ORXONOX_PLATFORM_APPLE 3 | 
|---|
 | 46 |  | 
|---|
 | 47 | #define ORXONOX_COMPILER_MSVC 1 | 
|---|
 | 48 | #define ORXONOX_COMPILER_GNUC 2 | 
|---|
 | 49 | #define ORXONOX_COMPILER_BORL 3 | 
|---|
 | 50 |  | 
|---|
 | 51 | #define ORXONOX_ENDIAN_LITTLE 1 | 
|---|
 | 52 | #define ORXONOX_ENDIAN_BIG 2 | 
|---|
 | 53 |  | 
|---|
 | 54 | #define ORXONOX_ARCHITECTURE_32 1 | 
|---|
 | 55 | #define ORXONOX_ARCHITECTURE_64 2 | 
|---|
 | 56 |  | 
|---|
| [1652] | 57 |  | 
|---|
 | 58 | /* Finds the compiler type and version. */ | 
|---|
 | 59 |  | 
|---|
| [1505] | 60 | #if defined( _MSC_VER ) | 
|---|
 | 61 | #  define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC | 
|---|
 | 62 | #  define ORXONOX_COMP_VER _MSC_VER | 
|---|
 | 63 |  | 
|---|
 | 64 | #elif defined( __GNUC__ ) | 
|---|
 | 65 | #  define ORXONOX_COMPILER ORXONOX_COMPILER_GNUC | 
|---|
 | 66 | #  define ORXONOX_COMP_VER (((__GNUC__)*100) + \ | 
|---|
 | 67 |         (__GNUC_MINOR__*10) + \ | 
|---|
 | 68 |         __GNUC_PATCHLEVEL__) | 
|---|
 | 69 |  | 
|---|
 | 70 | #elif defined( __BORLANDC__ ) | 
|---|
 | 71 | #  define ORXONOX_COMPILER ORXONOX_COMPILER_BORL | 
|---|
 | 72 | #  define ORXONOX_COMP_VER __BCPLUSPLUS__ | 
|---|
 | 73 |  | 
|---|
 | 74 | #else | 
|---|
 | 75 | #  pragma error "No known compiler. Abort! Abort!" | 
|---|
 | 76 |  | 
|---|
 | 77 | #endif | 
|---|
 | 78 |  | 
|---|
| [1652] | 79 |  | 
|---|
| [1505] | 80 | /* See if we can use __forceinline or if we need to use __inline instead */ | 
|---|
 | 81 | #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC | 
|---|
 | 82 | #  if ORXONOX_COMP_VER >= 1200 | 
|---|
 | 83 | #    define FORCEINLINE __forceinline | 
|---|
 | 84 | #  endif | 
|---|
 | 85 | #elif defined(__MINGW32__) | 
|---|
 | 86 | #  if !defined(FORCEINLINE) | 
|---|
 | 87 | #    define FORCEINLINE __inline | 
|---|
 | 88 | #  endif | 
|---|
 | 89 | #else | 
|---|
 | 90 | #  define FORCEINLINE __inline | 
|---|
 | 91 | #endif | 
|---|
 | 92 |  | 
|---|
 | 93 | /* Finds the current platform */ | 
|---|
 | 94 | #if defined( __WIN32__ ) || defined( _WIN32 ) | 
|---|
 | 95 | #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32 | 
|---|
 | 96 | #elif defined( __APPLE_CC__) | 
|---|
 | 97 | #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE | 
|---|
 | 98 | #else | 
|---|
 | 99 | #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX | 
|---|
 | 100 | #endif | 
|---|
 | 101 |  | 
|---|
| [1652] | 102 | /* Find the arch type */ | 
|---|
| [1505] | 103 | #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) | 
|---|
 | 104 | #  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64 | 
|---|
 | 105 | #else | 
|---|
 | 106 | #  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_32 | 
|---|
 | 107 | #endif | 
|---|
 | 108 |  | 
|---|
| [1652] | 109 | /* Try to define function information */ | 
|---|
| [1638] | 110 | #ifndef __FUNCTIONNAME__ | 
|---|
 | 111 | #  if ORXONOX_COMPILER == ORXONOX_COMPILER_BORL | 
|---|
 | 112 | #    define __FUNCTIONNAME__ __FUNC__ | 
|---|
 | 113 | #  elif ORXONOX_COMPILER == ORXONOX_COMPILER_GNUC | 
|---|
 | 114 | #    define __FUNCTIONNAME__ __PRETTY_FUNCTION__ | 
|---|
 | 115 | #  elif ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC | 
|---|
 | 116 | #    define __FUNCTIONNAME__ __FUNCTION__ | 
|---|
 | 117 | #  else | 
|---|
 | 118 | #    define __FUNCTIONNAME__ | 
|---|
 | 119 | #  endif | 
|---|
 | 120 | #endif | 
|---|
 | 121 |  | 
|---|
| [1652] | 122 | /* Determine whether we're building in debug mode */ | 
|---|
 | 123 | #if defined(_DEBUG) || defined(DEBUG) | 
|---|
 | 124 | #  define ORXONOX_DEBUG_MODE 1 | 
|---|
 | 125 | #else | 
|---|
 | 126 | #  define ORXONOX_DEBUG_MODE 0 | 
|---|
 | 127 | #endif | 
|---|
| [1505] | 128 |  | 
|---|
| [1652] | 129 | /* Define configurable floating point type */ | 
|---|
 | 130 | namespace orxonox | 
|---|
 | 131 | { | 
|---|
 | 132 | #ifdef ORXONOX_DOUBLE_PRECISION | 
|---|
 | 133 |     typedef double Real; | 
|---|
 | 134 | #else | 
|---|
 | 135 |     typedef float  Real; | 
|---|
 | 136 | #endif | 
|---|
 | 137 | } | 
|---|
| [1505] | 138 |  | 
|---|
 | 139 |  | 
|---|
| [1652] | 140 |  | 
|---|
 | 141 | /*--------------------------------- | 
|---|
 | 142 |  * Windows Settings | 
|---|
 | 143 |  *-------------------------------*/ | 
|---|
 | 144 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 | 
|---|
 | 145 | /* Disable unicode support on MingW at the moment, poorly supported in stdlibc++ | 
|---|
 | 146 |  * STLPORT fixes this though so allow if found | 
|---|
 | 147 |  * MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h */ | 
|---|
| [1505] | 148 | #  if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION) | 
|---|
 | 149 | #    include<_mingw.h> | 
|---|
 | 150 | #    if defined(__MINGW32_TOOLBOX_UNICODE__) | 
|---|
 | 151 | #      define ORXONOX_UNICODE_SUPPORT 1 | 
|---|
 | 152 | #    else | 
|---|
 | 153 | #      define ORXONOX_UNICODE_SUPPORT 0 | 
|---|
 | 154 | #    endif | 
|---|
 | 155 | #  else | 
|---|
 | 156 | #    define ORXONOX_UNICODE_SUPPORT 1 | 
|---|
 | 157 | #  endif | 
|---|
 | 158 | #endif /* Platform Win32 */ | 
|---|
 | 159 |  | 
|---|
| [1652] | 160 |  | 
|---|
 | 161 | /*--------------------------------- | 
|---|
 | 162 |  * Linux/Apple Settings | 
|---|
 | 163 |  *-------------------------------*/ | 
|---|
| [1505] | 164 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE | 
|---|
 | 165 |  | 
|---|
| [1652] | 166 | /* A quick define to overcome different names for the same function */ | 
|---|
| [1505] | 167 | #  define stricmp strcasecmp | 
|---|
 | 168 |  | 
|---|
| [1652] | 169 | /* TODO: Check what this actually is and whether we need it or not */ | 
|---|
 | 170 | #if 0 | 
|---|
| [1505] | 171 | #  if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE | 
|---|
 | 172 | #    define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle" | 
|---|
 | 173 | #  else | 
|---|
| [1652] | 174 | /* ORXONOX_PLATFORM_LINUX */ | 
|---|
| [1505] | 175 | #    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so" | 
|---|
 | 176 | #  endif | 
|---|
| [1652] | 177 | #endif | 
|---|
| [1505] | 178 |  | 
|---|
| [1652] | 179 | /* Always enable unicode support for the moment | 
|---|
 | 180 |  * Perhaps disable in old versions of gcc if necessary */ | 
|---|
| [1505] | 181 | #  define ORXONOX_UNICODE_SUPPORT 1 | 
|---|
 | 182 |  | 
|---|
 | 183 | #endif /* Patform Linux/Apple */ | 
|---|
 | 184 |  | 
|---|
| [1652] | 185 |  | 
|---|
 | 186 | /*--------------------------------- | 
|---|
 | 187 |  * Apple Settings | 
|---|
 | 188 |  *-------------------------------*/ | 
|---|
 | 189 | /* For apple, we always have a custom config.h file */ | 
|---|
| [1505] | 190 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE | 
|---|
 | 191 | #  include "config.h" | 
|---|
 | 192 | #endif | 
|---|
 | 193 |  | 
|---|
 | 194 |  | 
|---|
| [1652] | 195 | /*--------------------------------- | 
|---|
 | 196 |  * Visual Studio Settings | 
|---|
 | 197 |  *-------------------------------*/ | 
|---|
| [1505] | 198 | #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC | 
|---|
| [1652] | 199 | /* Turn off warnings generated by long std templates | 
|---|
 | 200 |  * This warns about truncation to 255 characters in debug/browse info */ | 
|---|
 | 201 | /*#   pragma warning (disable : 4786)*/ | 
|---|
| [1505] | 202 |  | 
|---|
| [1652] | 203 | /* Turn off warnings generated by long std templates | 
|---|
 | 204 |  * This warns about truncation to 255 characters in debug/browse info */ | 
|---|
 | 205 | /*#   pragma warning (disable : 4503)*/ | 
|---|
| [1505] | 206 |  | 
|---|
| [1652] | 207 | /* disable: conversion from 'double' to 'float', possible loss of data | 
|---|
 | 208 |  * disable: conversion from 'ogg_int64_t' to 'long', possible loss of data | 
|---|
 | 209 |  * This has been dealt with in base_properties of the solution since the | 
|---|
 | 210 |  * warning primarily occurs in library header files (which are mostly | 
|---|
 | 211 |  * included before OrxonoxPlatform.h is) */ | 
|---|
 | 212 | /*#   pragma warning (disable : 4244)*/ | 
|---|
| [1505] | 213 |  | 
|---|
| [1652] | 214 | /* disable: "conversion from 'size_t' to 'unsigned int', possible loss of data */ | 
|---|
 | 215 | /*#   pragma warning (disable : 4267)*/ | 
|---|
| [1505] | 216 |  | 
|---|
| [1652] | 217 | /* disable: "truncation from 'double' to 'float' */ | 
|---|
 | 218 | /*#   pragma warning (disable : 4305)*/ | 
|---|
| [1505] | 219 |  | 
|---|
| [1652] | 220 | /* set to level 4: "<type> needs to have dll-interface to be used by clients' | 
|---|
 | 221 |  * Happens on STL member variables which are not public therefore is ok */ | 
|---|
| [1505] | 222 | #   pragma warning (disable : 4251) | 
|---|
 | 223 |  | 
|---|
| [1652] | 224 | /* disable: 'MultiTypeString' : multiple assignment operators specified | 
|---|
 | 225 |  * Used in MultiType and works fine so far */ | 
|---|
 | 226 | /*#   pragma warning (disable : 4522)*/ | 
|---|
| [1505] | 227 |  | 
|---|
| [1652] | 228 | /* disable: "non dll-interface class used as base for dll-interface class" | 
|---|
 | 229 |  * Happens when deriving from Singleton because bug in compiler ignores | 
|---|
 | 230 |  * template export */ | 
|---|
 | 231 | /*#   pragma warning (disable : 4275)*/ | 
|---|
| [1505] | 232 |  | 
|---|
| [1652] | 233 | /* disable: "C++ Exception Specification ignored" | 
|---|
 | 234 |  * This is because MSVC 6 did not implement all the C++ exception | 
|---|
 | 235 |  * specifications in the ANSI C++ draft. */ | 
|---|
 | 236 | /*#   pragma warning( disable : 4290 )*/ | 
|---|
| [1505] | 237 |  | 
|---|
| [1652] | 238 | /* disable: "no suitable definition provided for explicit template | 
|---|
 | 239 |  * instantiation request" Occurs in VC7 for no justifiable reason on all | 
|---|
 | 240 |  * #includes of Singleton */ | 
|---|
 | 241 | /*#   pragma warning( disable: 4661)*/ | 
|---|
| [1505] | 242 |  | 
|---|
| [1652] | 243 | /* disable: deprecation warnings when using CRT calls in VC8 | 
|---|
 | 244 |  * These show up on all C runtime lib code in VC8, disable since they clutter | 
|---|
 | 245 |  * the warnings with things we may not be able to do anything about (e.g. | 
|---|
 | 246 |  * generated code from nvparse etc). I doubt very much that these calls | 
|---|
 | 247 |  * will ever be actually removed from VC anyway, it would break too much code. */ | 
|---|
 | 248 | /*# pragma warning( disable: 4996)*/ | 
|---|
| [1505] | 249 |  | 
|---|
| [1652] | 250 | /* disable: "conditional expression constant", always occurs on | 
|---|
 | 251 |  * ORXONOX_MUTEX_CONDITIONAL when no threading enabled */ | 
|---|
 | 252 | /*#   pragma warning (disable : 201)*/ | 
|---|
| [1505] | 253 |  | 
|---|
 | 254 |  | 
|---|
| [1652] | 255 | /* Define the english written operators like and, or, xor */ | 
|---|
| [1505] | 256 | #include <iso646.h> | 
|---|
 | 257 |  | 
|---|
| [1652] | 258 | /* include visual leak detector to search for memory leaks */ | 
|---|
 | 259 | /* #include <vld.h> */ | 
|---|
 | 260 |  | 
|---|
| [1505] | 261 | #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */ | 
|---|
 | 262 |  | 
|---|
 | 263 | #endif /* _OrxonoxPlatform_H__ */ | 
|---|