4 #defines for platform specific issues.
6 @maintainer Morgan McGuire, matrix@graphics3d.com
12 #ifndef G3D_PLATFORM_H
13 #define G3D_PLATFORM_H
16 The version number of G3D in the form: MmmBB ->
17 version M.mm [beta BB]
21 #if defined(G3D_RELEASEDEBUG)
22 # define G3D_DEBUGRELEASE
25 #if defined(G3D_DEBUGRELEASE) && defined(_DEBUG)
29 #if !defined(G3D_DEBUG) && (defined(_DEBUG) || defined(G3D_DEBUGRELEASE))
35 #elif defined(__MINGW32__)
38 #elif defined(__linux__)
40 #elif defined(__OpenBSD__)
42 #elif defined(__FreeBSD__)
44 #elif defined(__NetBSD__)
46 #elif defined(__APPLE__)
49 #error Unknown platform
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")
61 // Turn off warnings about deprecated C routines (TODO: revisit)
62 # pragma warning (disable : 4996)
65 // On g++, recognize cases where the -msse2 flag was not specified
66 #if defined(SSE) && defined(__GNUC__) && ! defined (__SSE__)
71 # if __STDC_VERSION__ < 199901
72 # define restrict __restrict__
77 // Verify that the supported compilers are being used and that this is a known
82 # error G3D only supports the gcc compiler on Linux.
86 //# error G3D only supports x86 machines on Linux.
89 # define G3D_DEPRECATED __attribute__((__deprecated__))
92 # define __cdecl __attribute__((cdecl))
96 # define __stdcall __attribute__((stdcall))
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)))
108 #error G3D only supports the gcc compiler on OS X.
111 #if defined(__i386__)
112 #define G3D_OSX_INTEL
113 #elif defined(__PPC__)
116 #define G3D_OSX_UNKNOWN
120 # define __cdecl __attribute__((cdecl))
124 # define __stdcall __attribute__((stdcall))
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)))
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
150 # if (_MSC_VER <= 1200)
151 // Nothing we can do on VC6 for deprecated functions
152 # define G3D_DEPRECATED
154 # define G3D_DEPRECATED __declspec(deprecated)
157 // Prevent Winsock conflicts by hiding the winsock API
159 # define _G3D_INTERNAL_HIDE_WINSOCK_
160 # define _WINSOCKAPI_
163 // Disable 'name too long for browse information' warning
164 # pragma warning (disable : 4786)
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)
175 // Mingw32 defines restrict
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
201 // Multithreaded runtime
205 // Ensure that we aren't forced into the static lib
206 #ifdef _STATIC_CPPLIB
207 #undef _STATIC_CPPLIB
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")
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")
225 // Now set up external linking
228 // zlib and SDL were linked against the release MSVCRT; force
229 // the debug version.
230 #pragma comment(linker, "/NODEFAULTLIB:MSVCRT.LIB")
233 # ifndef WIN32_LEAN_AND_MEAN
234 # define WIN32_LEAN_AND_MEAN 1
239 # include <windows.h>
240 # undef WIN32_LEAN_AND_MEAN
243 #ifdef _G3D_INTERNAL_HIDE_WINSOCK_
244 # undef _G3D_INTERNAL_HIDE_WINSOCK_
250 # if defined(_MSC_VER) && (_MSC_VER <= 1200)
251 // VC6 std:: has signed/unsigned problems
252 # pragma warning (disable : 4018)
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>
265 #undef G3D_DEPRECATED
266 #define G3D_DEPRECATED