source: nrEngine/include/Platform.h @ 1

Revision 1, 4.9 KB checked in by art, 14 years ago (diff)
Line 
1/***************************************************************************
2 *                                                                         *
3 *   (c) Art Tevs, MPI Informatik Saarbruecken                             *
4 *       mailto: <tevs@mpi-sb.mpg.de>                                      *
5 *                                                                         *
6 *   This program is free software; you can redistribute it and/or modify  *
7 *   it under the terms of the GNU General Public License as published by  *
8 *   the Free Software Foundation; either version 2 of the License, or     *
9 *   (at your option) any later version.                                   *
10 *                                                                         *
11 ***************************************************************************
12 *                                                                         *
13 * Parts of this file was get from OGRE (Object-oriented Graphics          *
14 * Rendering Engine). see http://www.ogre3d.org                            *
15 * Copyright (c) 2000-2005 The OGRE Team                                   *
16 **************************************************************************/
17#ifndef __NR_PLATFORM_H_
18#define __NR_PLATFORM_H_
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24/* Initial platform/compiler-related stuff to set.
25*/
26#define NR_PLATFORM_WIN32 1
27#define NR_PLATFORM_LINUX 2
28#define NR_PLATFORM_APPLE 3
29#define NR_PLATFORM_NETWARE 4
30#define NR_PLATFORM_OS2         5
31
32#define NR_COMPILER_MSVC 1
33#define NR_COMPILER_GNUC 2
34#define NR_COMPILER_BORL 3
35
36#define NR_ENDIAN_LITTLE 1
37#define NR_ENDIAN_BIG 2
38
39#define NR_ARCHITECTURE_32 1
40#define NR_ARCHITECTURE_64 2
41
42/* Finds the compiler type and version.
43*/
44#if defined( _MSC_VER )
45#   define NR_COMPILER NR_COMPILER_MSVC
46#   define NR_COMP_VER _MSC_VER
47
48#elif defined( __GNUC__ )
49#   define NR_COMPILER NR_COMPILER_GNUC
50#   define NR_COMP_VER (((__GNUC__)*100)+__GNUC_MINOR__)
51
52#elif defined( __BORLANDC__ )
53#   define NR_COMPILER NR_COMPILER_BORL
54#   define NR_COMP_VER __BCPLUSPLUS__
55
56#else
57#   pragma warning "No known compiler. Behaivor is not defined :-)"
58
59#endif
60
61/* See if we can use __forceinline or if we need to use __inline instead */
62#if NR_COMPILER == NR_COMPILER_MSVC
63#   if NR_COMP_VER >= 1200
64#       define NR_FORCEINLINE __forceinline
65#   endif
66#else
67#   define NR_FORCEINLINE __inline
68#endif
69
70
71/* Finds the current platform */
72#if defined( __WIN32__ ) || defined( _WIN32 )
73#   define NR_PLATFORM NR_PLATFORM_WIN32
74#elif defined( __APPLE_CC__)
75#   define NR_PLATFORM NR_PLATFORM_APPLE
76#else
77#   define NR_PLATFORM NR_PLATFORM_LINUX
78#endif
79
80
81/* Find the arch type */
82#if defined(__x86_64__)
83#   define NR_ARCH_TYPE NR_ARCHITECTURE_64
84#else
85#   define NR_ARCH_TYPE NR_ARCHITECTURE_32
86#endif
87
88
89//----------------------------------------------------------------------------
90// Windows Settings
91#if NR_PLATFORM == NR_PLATFORM_WIN32
92#include <windows.h>
93// If we're not including this from a client build, specify that the stuff
94// should get exported. Otherwise, import it.
95#if defined( NONCLIENT_BUILD ) || defined ( BUILDING_DLL ) || defined (BUILD_DLL)
96#       define _NRExport __declspec( dllexport )
97#elif defined (BUILDING_PLUGIN) || defined (BUILD_PLUGIN) || defined (CLIENT_BUILD)
98#       define _NRExport __declspec( dllimport )
99#else
100#   define _NRExport
101#endif
102
103// Win32 compilers use _DEBUG for specifying debug builds.
104#   ifdef _DEBUG
105#       define NR_DEBUG_MODE 1
106#   else
107#       define NR_DEBUG_MODE 0
108#   endif
109
110// Check for mingw compilers
111#if defined( __MINGW32__ )
112    #define GCC_3_1
113    #define EXT_HASH
114#else
115    #define snprintf _snprintf
116    #define vsnprintf _vsnprintf
117#endif
118
119#endif
120//----------------------------------------------------------------------------
121
122
123//----------------------------------------------------------------------------
124// Linux/Apple Settings
125#if NR_PLATFORM == NR_PLATFORM_LINUX || NR_PLATFORM == NR_PLATFORM_APPLE
126
127// Linux compilers don't have symbol import/export directives.
128#   define _NRExport
129
130// A quick define to overcome different names for the same function
131#   define stricmp strcasecmp
132
133// Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
134// specifying a debug build.
135#   ifdef DEBUG
136#       define NR_DEBUG_MODE 1
137#   else
138#       define NR_DEBUG_MODE 0
139#   endif
140
141#endif
142
143//For apple, we always have a custom config.h file
144#if NR_PLATFORM == NR_PLATFORM_APPLE
145#    include "config.h"
146//SDL_main must be included in the file that contains
147//the application's main() function.
148// #ifndef NONCLIENT_BUILD
149// #   include <SDL/SDL_main.h>
150// #endif
151
152#endif
153//----------------------------------------------------------------------------
154
155
156//----------------------------------------------------------------------------
157// Endian Settings
158// check for BIG_ENDIAN config flag, set NR_ENDIAN correctly
159#ifdef CONFIG_BIG_ENDIAN
160#    define NR_ENDIAN NR_ENDIAN_BIG
161#else
162#    define NR_ENDIAN NR_ENDIAN_LITTLE
163#endif
164
165
166#endif
Note: See TracBrowser for help on using the repository browser.