Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/util/OrxonoxPlatform.h @ 1638

Last change on this file since 1638 was 1638, checked in by rgrieder, 16 years ago

merged input branch into gui test branch (was about time)
svn save (it's still a mess and CMLs haven't been updated)
I'll have to create a special project to create the tolua_bind files for tolua itself anyway..

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