Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / include / g3dlite / G3D / platform.h
blobfed9c7b53243983bdb13bd088d9ac5b46c868951
1 /**
2 @file platform.h
4 #defines for platform specific issues.
6 @maintainer Morgan McGuire, matrix@graphics3d.com
8 @created 2003-06-09
9 @edited 2006-01-16
12 #ifndef G3D_PLATFORM_H
13 #define G3D_PLATFORM_H
15 /**
16 The version number of G3D in the form: MmmBB ->
17 version M.mm [beta BB]
19 #define G3D_VER 61000
21 #if defined(G3D_RELEASEDEBUG)
22 # define G3D_DEBUGRELEASE
23 #endif
25 #if defined(G3D_DEBUGRELEASE) && defined(_DEBUG)
26 # undef _DEBUG
27 #endif
29 #if !defined(G3D_DEBUG) && (defined(_DEBUG) || defined(G3D_DEBUGRELEASE))
30 # define G3D_DEBUG
31 #endif
33 #ifdef _MSC_VER
34 #define G3D_WIN32
35 #elif defined(__MINGW32__)
36 #define G3D_WIN32
37 #define G3D_MINGW32
38 #elif defined(__linux__)
39 #define G3D_LINUX
40 #elif defined(__OpenBSD__)
41 #define G3D_LINUX
42 #elif defined(__FreeBSD__)
43 #define G3D_LINUX
44 #elif defined(__NetBSD__)
45 #define G3D_LINUX
46 #elif defined(__APPLE__)
47 #define G3D_OSX
48 #else
49 #error Unknown platform
50 #endif
53 // Default to compiling with SSE, but if you want to compile
54 // without installing SP5.0 and the Processor Pack on Windows, compile with NO_SSE
55 // defined (can be passed to the compiler command line with /D "NO_SSE")
56 #if !defined(NO_SSE)
57 #define SSE
58 #endif
60 #ifdef G3D_WIN32
61 // Turn off warnings about deprecated C routines (TODO: revisit)
62 # pragma warning (disable : 4996)
63 #endif
65 // On g++, recognize cases where the -msse2 flag was not specified
66 #if defined(SSE) && defined(__GNUC__) && ! defined (__SSE__)
67 # undef SSE
68 #endif
70 #if defined(__GNUC__)
71 # if __STDC_VERSION__ < 199901
72 # define restrict __restrict__
73 # endif
74 #endif
77 // Verify that the supported compilers are being used and that this is a known
78 // processor.
80 #ifdef G3D_LINUX
81 # ifndef __GNUC__
82 # error G3D only supports the gcc compiler on Linux.
83 # endif
85 //# ifndef __i386__
86 //# error G3D only supports x86 machines on Linux.
87 //# endif
89 # define G3D_DEPRECATED __attribute__((__deprecated__))
91 # ifndef __cdecl
92 # define __cdecl __attribute__((cdecl))
93 # endif
95 # ifndef __stdcall
96 # define __stdcall __attribute__((stdcall))
97 # endif
99 # define G3D_CHECK_PRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 3)))
100 # define G3D_CHECK_VPRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 0)))
101 # define G3D_CHECK_PRINTF_ARGS __attribute__((__format__(__printf__, 1, 2)))
102 # define G3D_CHECK_VPRINTF_ARGS __attribute__((__format__(__printf__, 1, 0)))
103 #endif
106 #ifdef G3D_OSX
107 #ifndef __GNUC__
108 #error G3D only supports the gcc compiler on OS X.
109 #endif
111 #if defined(__i386__)
112 #define G3D_OSX_INTEL
113 #elif defined(__PPC__)
114 #define G3D_OSX_PPC
115 #else
116 #define G3D_OSX_UNKNOWN
117 #endif
119 # ifndef __cdecl
120 # define __cdecl __attribute__((cdecl))
121 # endif
123 # ifndef __stdcall
124 # define __stdcall __attribute__((stdcall))
125 # endif
127 # define G3D_DEPRECATED __attribute__((__deprecated__))
129 # define G3D_CHECK_PRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 3)))
130 # define G3D_CHECK_VPRINTF_METHOD_ARGS __attribute__((__format__(__printf__, 2, 0)))
131 # define G3D_CHECK_PRINTF_ARGS __attribute__((__format__(__printf__, 1, 2)))
132 # define G3D_CHECK_VPRINTF_ARGS __attribute__((__format__(__printf__, 1, 0)))
133 #endif
136 #ifdef G3D_WIN32
137 // Microsoft Visual C++ 7.1 _MSC_VER = 1310
138 // Microsoft Visual C++ 7.0 _MSC_VER = 1300
139 // Microsoft Visual C++ 6.0 _MSC_VER = 1200
140 // Microsoft Visual C++ 5.0 _MSC_VER = 1100
142 // Old versions of MSVC (6.0 and previous) don't
143 // support C99 for loop scoping rules. This fixes them.
144 # if (_MSC_VER <= 1200)
145 // This trick will generate a warning; disable the warning
146 # pragma warning (disable : 4127)
147 # define for if (false) {} else for
148 # endif
150 # if (_MSC_VER <= 1200)
151 // Nothing we can do on VC6 for deprecated functions
152 # define G3D_DEPRECATED
153 # else
154 # define G3D_DEPRECATED __declspec(deprecated)
155 # endif
157 // Prevent Winsock conflicts by hiding the winsock API
158 #ifndef _WINSOCKAPI_
159 # define _G3D_INTERNAL_HIDE_WINSOCK_
160 # define _WINSOCKAPI_
161 # endif
163 // Disable 'name too long for browse information' warning
164 # pragma warning (disable : 4786)
165 // TODO: remove
166 # pragma warning (disable : 4244)
168 # if defined(_MSC_VER) && (_MSC_VER <= 1200)
169 // VC6 std:: has signed problems in it
170 # pragma warning (disable : 4018)
171 # endif
173 # define ZLIB_WINAPI
175 // Mingw32 defines restrict
176 # ifndef G3D_MINGW32
177 # define restrict
178 # endif
180 # define G3D_CHECK_PRINTF_ARGS
181 # define G3D_CHECK_VPRINTF_ARGS
182 # define G3D_CHECK_PRINTF_METHOD_ARGS
183 # define G3D_CHECK_VPRINTF_METHOD_ARGS
185 // On MSVC, we need to link against the multithreaded DLL version of
186 // the C++ runtime because that is what SDL and ZLIB are compiled
187 // against. This is not the default for MSVC, so we set the following
188 // defines to force correct linking.
190 // For documentation on compiler options, see:
191 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_.2f.md.2c_2f.ml.2c_2f.mt.2c_2f.ld.asp
192 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_Compiler_Reference.asp
195 #if 0 //ignore that for mangos
196 // DLL runtime
197 #ifndef _DLL
198 #define _DLL
199 #endif
201 // Multithreaded runtime
202 #ifndef _MT
203 #define _MT 1
204 #endif
205 // Ensure that we aren't forced into the static lib
206 #ifdef _STATIC_CPPLIB
207 #undef _STATIC_CPPLIB
208 #endif
209 #endif
211 #ifdef _DEBUG
212 #pragma comment (linker, "/NODEFAULTLIB:libc.lib")
213 #pragma comment (linker, "/NODEFAULTLIB:libcmt.lib")
214 #pragma comment (linker, "/NODEFAULTLIB:msvcrt.lib")
215 #pragma comment (linker, "/NODEFAULTLIB:libcd.lib")
216 #pragma comment (linker, "/NODEFAULTLIB:msvcrtd.lib")
217 #else
218 #pragma comment(linker, "/NODEFAULTLIB:LIBC.LIB")
219 #pragma comment(linker, "/NODEFAULTLIB:msvcrt.lib")
220 #pragma comment(linker, "/NODEFAULTLIB:libcd.lib")
221 #pragma comment(linker, "/NODEFAULTLIB:libcmtd.lib")
222 #pragma comment(linker, "/NODEFAULTLIB:msvcrtd.lib")
223 #endif
225 // Now set up external linking
227 #ifdef _DEBUG
228 // zlib and SDL were linked against the release MSVCRT; force
229 // the debug version.
230 #pragma comment(linker, "/NODEFAULTLIB:MSVCRT.LIB")
231 # endif
233 # ifndef WIN32_LEAN_AND_MEAN
234 # define WIN32_LEAN_AND_MEAN 1
235 # endif
238 # define NOMINMAX 1
239 # include <windows.h>
240 # undef WIN32_LEAN_AND_MEAN
241 # undef NOMINMAX
243 #ifdef _G3D_INTERNAL_HIDE_WINSOCK_
244 # undef _G3D_INTERNAL_HIDE_WINSOCK_
245 # undef _WINSOCKAPI_
246 #endif
248 #endif
250 # if defined(_MSC_VER) && (_MSC_VER <= 1200)
251 // VC6 std:: has signed/unsigned problems
252 # pragma warning (disable : 4018)
253 # endif
255 /**
256 @def STR(expression)
258 Creates a string from the expression. Frequently used with G3D::Shader
259 to express shading programs inline.
261 <CODE>STR(this becomes a string)<PRE> evaluates the same as <CODE>"this becomes a string"</CODE>
263 #define STR(x) #x
265 #undef G3D_DEPRECATED
266 #define G3D_DEPRECATED
268 // Header guard
269 #endif