[682] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1056] | 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 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
[1032] | 30 | @file |
---|
[682] | 31 | @brief Various constants for compiler, architecture and platform. It's a mere |
---|
| 32 | copy of the file found in the Ogre source code (OgrePlatform.h). |
---|
| 33 | */ |
---|
| 34 | |
---|
| 35 | #ifndef _OrxonoxPlatform_H__ |
---|
| 36 | #define _OrxonoxPlatform_H__ |
---|
| 37 | |
---|
| 38 | namespace orxonox { |
---|
| 39 | /* Initial platform/compiler-related stuff to set. |
---|
| 40 | */ |
---|
| 41 | #define ORXONOX_PLATFORM_WIN32 1 |
---|
| 42 | #define ORXONOX_PLATFORM_LINUX 2 |
---|
| 43 | #define ORXONOX_PLATFORM_APPLE 3 |
---|
| 44 | |
---|
| 45 | #define ORXONOX_COMPILER_MSVC 1 |
---|
| 46 | #define ORXONOX_COMPILER_GNUC 2 |
---|
| 47 | #define ORXONOX_COMPILER_BORL 3 |
---|
| 48 | |
---|
| 49 | #define ORXONOX_ENDIAN_LITTLE 1 |
---|
| 50 | #define ORXONOX_ENDIAN_BIG 2 |
---|
| 51 | |
---|
| 52 | #define ORXONOX_ARCHITECTURE_32 1 |
---|
| 53 | #define ORXONOX_ARCHITECTURE_64 2 |
---|
| 54 | |
---|
| 55 | /* Finds the compiler type and version. |
---|
| 56 | */ |
---|
| 57 | #if defined( _MSC_VER ) |
---|
| 58 | # define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC |
---|
| 59 | # define ORXONOX_COMP_VER _MSC_VER |
---|
| 60 | |
---|
| 61 | #elif defined( __GNUC__ ) |
---|
| 62 | # define ORXONOX_COMPILER ORXONOX_COMPILER_GNUC |
---|
| 63 | # define ORXONOX_COMP_VER (((__GNUC__)*100) + \ |
---|
| 64 | (__GNUC_MINOR__*10) + \ |
---|
| 65 | __GNUC_PATCHLEVEL__) |
---|
| 66 | |
---|
| 67 | #elif defined( __BORLANDC__ ) |
---|
| 68 | # define ORXONOX_COMPILER ORXONOX_COMPILER_BORL |
---|
| 69 | # define ORXONOX_COMP_VER __BCPLUSPLUS__ |
---|
| 70 | |
---|
| 71 | #else |
---|
| 72 | # pragma error "No known compiler. Abort! Abort!" |
---|
| 73 | |
---|
| 74 | #endif |
---|
| 75 | |
---|
| 76 | /* See if we can use __forceinline or if we need to use __inline instead */ |
---|
| 77 | #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC |
---|
| 78 | # if ORXONOX_COMP_VER >= 1200 |
---|
| 79 | # define FORCEINLINE __forceinline |
---|
| 80 | # endif |
---|
| 81 | #elif defined(__MINGW32__) |
---|
| 82 | # if !defined(FORCEINLINE) |
---|
| 83 | # define FORCEINLINE __inline |
---|
| 84 | # endif |
---|
| 85 | #else |
---|
| 86 | # define FORCEINLINE __inline |
---|
| 87 | #endif |
---|
| 88 | |
---|
| 89 | /* Finds the current platform */ |
---|
| 90 | |
---|
| 91 | #if defined( __WIN32__ ) || defined( _WIN32 ) |
---|
| 92 | # define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32 |
---|
| 93 | |
---|
| 94 | #elif defined( __APPLE_CC__) |
---|
| 95 | # define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE |
---|
| 96 | |
---|
| 97 | #else |
---|
| 98 | # define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX |
---|
| 99 | #endif |
---|
| 100 | |
---|
| 101 | /* Find the arch type */ |
---|
| 102 | #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) |
---|
| 103 | # define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64 |
---|
| 104 | #else |
---|
| 105 | # define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_32 |
---|
| 106 | #endif |
---|
| 107 | |
---|
| 108 | // For generating compiler warnings - should work on any compiler |
---|
| 109 | // As a side note, if you start your message with 'Warning: ', the MSVC |
---|
| 110 | // IDE actually does catch a warning :) |
---|
[1032] | 111 | // FIXME: Try this on linux box. Doesn't work with msvc |
---|
| 112 | //#define ORXONOX_QUOTE_INPLACE(x) # x |
---|
| 113 | //#define ORXONOX_QUOTE(x) ORXONOX_QUOTE_INPLACE(x) |
---|
| 114 | //#define ORXONOX_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" ) |
---|
[682] | 115 | |
---|
| 116 | //---------------------------------------------------------------------------- |
---|
| 117 | // Windows Settings |
---|
| 118 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 |
---|
| 119 | |
---|
| 120 | // Win32 compilers use _DEBUG for specifying debug builds. |
---|
| 121 | # ifdef _DEBUG |
---|
| 122 | # define ORXONOX_DEBUG_MODE 1 |
---|
| 123 | # else |
---|
| 124 | # define ORXONOX_DEBUG_MODE 0 |
---|
| 125 | # endif |
---|
| 126 | |
---|
| 127 | // Disable unicode support on MingW at the moment, poorly supported in stdlibc++ |
---|
| 128 | // STLPORT fixes this though so allow if found |
---|
| 129 | // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h |
---|
| 130 | # if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION) |
---|
| 131 | # include<_mingw.h> |
---|
| 132 | # if defined(__MINGW32_TOOLBOX_UNICODE__) |
---|
| 133 | # define ORXONOX_UNICODE_SUPPORT 1 |
---|
| 134 | # else |
---|
| 135 | # define ORXONOX_UNICODE_SUPPORT 0 |
---|
| 136 | # endif |
---|
| 137 | # else |
---|
| 138 | # define ORXONOX_UNICODE_SUPPORT 1 |
---|
| 139 | # endif |
---|
| 140 | |
---|
[1032] | 141 | #endif /* Platform Win32 */ |
---|
[682] | 142 | //---------------------------------------------------------------------------- |
---|
| 143 | |
---|
| 144 | //---------------------------------------------------------------------------- |
---|
| 145 | // Linux/Apple Settings |
---|
| 146 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | // A quick define to overcome different names for the same function |
---|
| 150 | # define stricmp strcasecmp |
---|
| 151 | |
---|
| 152 | // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when |
---|
| 153 | // specifying a debug build. |
---|
| 154 | // (??? this is wrong, on Linux debug builds aren't marked in any way unless |
---|
| 155 | // you mark it yourself any way you like it -- zap ???) |
---|
| 156 | # ifdef DEBUG |
---|
| 157 | # define ORXONOX_DEBUG_MODE 1 |
---|
| 158 | # else |
---|
| 159 | # define ORXONOX_DEBUG_MODE 0 |
---|
| 160 | # endif |
---|
| 161 | |
---|
| 162 | /* FIXME: Check what this actually is and whether we need it or not |
---|
| 163 | # if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
| 164 | # define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle" |
---|
| 165 | # else |
---|
| 166 | // ORXONOX_PLATFORM_LINUX |
---|
| 167 | # define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so" |
---|
| 168 | # endif |
---|
| 169 | */ |
---|
| 170 | |
---|
| 171 | // Always enable unicode support for the moment |
---|
| 172 | // Perhaps disable in old versions of gcc if necessary |
---|
| 173 | # define ORXONOX_UNICODE_SUPPORT 1 |
---|
| 174 | |
---|
[1032] | 175 | #endif /* Patform Linux/Apple */ |
---|
[682] | 176 | |
---|
| 177 | //For apple, we always have a custom config.h file |
---|
| 178 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
| 179 | # include "config.h" |
---|
| 180 | #endif |
---|
| 181 | |
---|
| 182 | //---------------------------------------------------------------------------- |
---|
| 183 | |
---|
| 184 | //---------------------------------------------------------------------------- |
---|
| 185 | // Endian Settings |
---|
| 186 | // check for BIG_ENDIAN config flag, set ORXONOX_ENDIAN correctly |
---|
| 187 | #ifdef ORXONOX_CONFIG_BIG_ENDIAN |
---|
| 188 | # define ORXONOX_ENDIAN ORXONOX_ENDIAN_BIG |
---|
| 189 | #else |
---|
| 190 | # define ORXONOX_ENDIAN ORXONOX_ENDIAN_LITTLE |
---|
| 191 | #endif |
---|
| 192 | |
---|
| 193 | // Integer formats of fixed bit width |
---|
[1024] | 194 | // FIXME: consider 64 bit platforms! |
---|
[1032] | 195 | //typedef unsigned int uint32; |
---|
| 196 | //typedef unsigned short uint16; |
---|
| 197 | //typedef unsigned char uint8; |
---|
[682] | 198 | |
---|
[708] | 199 | #ifdef ORXONOX_DOUBLE_PRECISION |
---|
| 200 | typedef double Real; |
---|
| 201 | #else |
---|
| 202 | typedef float Real; |
---|
| 203 | #endif |
---|
[682] | 204 | |
---|
| 205 | |
---|
[683] | 206 | #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC |
---|
[682] | 207 | // Turn off warnings generated by long std templates |
---|
| 208 | // This warns about truncation to 255 characters in debug/browse info |
---|
| 209 | //# pragma warning (disable : 4786) |
---|
| 210 | |
---|
| 211 | // Turn off warnings generated by long std templates |
---|
| 212 | // This warns about truncation to 255 characters in debug/browse info |
---|
| 213 | //# pragma warning (disable : 4503) |
---|
| 214 | |
---|
[1021] | 215 | // disable: conversion from 'double' to 'float', possible loss of data |
---|
| 216 | // disable: conversion from 'ogg_int64_t' to 'long', possible loss of data |
---|
| 217 | // This has been dealt with in base_properties of the solution since the |
---|
| 218 | // warning primarily occurs in library header files (which are mostly |
---|
| 219 | // included before OrxonoxPlatform.h is) |
---|
[782] | 220 | //# pragma warning (disable : 4244) |
---|
[682] | 221 | |
---|
[768] | 222 | // disable: "conversion from 'size_t' to 'unsigned int', possible loss of data |
---|
[782] | 223 | //# pragma warning (disable : 4267) |
---|
[768] | 224 | |
---|
[682] | 225 | // disable: "truncation from 'double' to 'float' |
---|
| 226 | //# pragma warning (disable : 4305) |
---|
| 227 | |
---|
[1064] | 228 | // set to level 4: "<type> needs to have dll-interface to be used by clients' |
---|
[682] | 229 | // Happens on STL member variables which are not public therefore is ok |
---|
[1064] | 230 | # pragma warning (disable : 4251) |
---|
[682] | 231 | |
---|
[1021] | 232 | // disable: 'MultiTypeString' : multiple assignment operators specified |
---|
| 233 | // Used in MultiType and works fine so far |
---|
[1024] | 234 | //# pragma warning (disable : 4522) |
---|
[1021] | 235 | |
---|
[682] | 236 | // disable: "non dll-interface class used as base for dll-interface class" |
---|
| 237 | // Happens when deriving from Singleton because bug in compiler ignores |
---|
| 238 | // template export |
---|
| 239 | //# pragma warning (disable : 4275) |
---|
| 240 | |
---|
| 241 | // disable: "C++ Exception Specification ignored" |
---|
| 242 | // This is because MSVC 6 did not implement all the C++ exception |
---|
| 243 | // specifications in the ANSI C++ draft. |
---|
| 244 | //# pragma warning( disable : 4290 ) |
---|
| 245 | |
---|
| 246 | // disable: "no suitable definition provided for explicit template |
---|
| 247 | // instantiation request" Occurs in VC7 for no justifiable reason on all |
---|
| 248 | // #includes of Singleton |
---|
| 249 | //# pragma warning( disable: 4661) |
---|
| 250 | |
---|
| 251 | // disable: deprecation warnings when using CRT calls in VC8 |
---|
| 252 | // These show up on all C runtime lib code in VC8, disable since they clutter |
---|
| 253 | // the warnings with things we may not be able to do anything about (e.g. |
---|
| 254 | // generated code from nvparse etc). I doubt very much that these calls |
---|
| 255 | // will ever be actually removed from VC anyway, it would break too much code. |
---|
| 256 | //# pragma warning( disable: 4996) |
---|
| 257 | |
---|
[1056] | 258 | // disable: "conditional expression constant", always occurs on |
---|
[683] | 259 | // ORXONOX_MUTEX_CONDITIONAL when no threading enabled |
---|
[682] | 260 | //# pragma warning (disable : 201) |
---|
| 261 | |
---|
| 262 | |
---|
[1021] | 263 | // Define the english written operators like and, or, xor |
---|
[1032] | 264 | #include <iso646.h> |
---|
[890] | 265 | |
---|
[1032] | 266 | #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */ |
---|
[682] | 267 | |
---|
[1032] | 268 | // include visual leak detector to search for memory leaks |
---|
[1024] | 269 | //#include <vld.h> |
---|
| 270 | |
---|
[1032] | 271 | } /* namespace orxonox */ |
---|
| 272 | |
---|
[682] | 273 | #endif /* _OrxonoxPlatform_H__ */ |
---|