2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * This file sets things up for C dynamic library function definitions,
26 * static inlined functions, and structures aligned at 4-byte alignment.
27 * If you don't like ugly C preprocessor code, don't look at this file. :)
32 * This shouldn't be nested -- included it around code only.
35 #error Nested inclusion of begin_code.h
41 * Some compilers use a special export keyword
44 # if defined(__BEOS__) || defined(__HAIKU__)
45 # if defined(__GNUC__)
46 # define DECLSPEC __declspec(dllexport)
48 # define DECLSPEC __declspec(export)
50 # elif defined(__WIN32__)
55 # define DECLSPEC __declspec(dllimport)
58 # define DECLSPEC __declspec(dllexport)
60 # elif defined(__OS2__)
63 # define DECLSPEC __declspec(dllexport)
67 # elif defined (__GNUC__) && __GNUC__ < 4
68 # /* Added support for GCC-EMX <v4.x */
69 # /* this is needed for XFree86/OS2 developement */
70 # /* F. Ambacher(anakor@snafu.de) 05.2008 */
72 # define DECLSPEC __declspec(dllexport)
80 # if defined(__GNUC__) && __GNUC__ >= 4
81 # define DECLSPEC __attribute__ ((visibility("default")))
90 * By default SDL uses the C calling convention
93 # if defined(__WIN32__) && !defined(__GNUC__)
94 # define SDLCALL __cdecl
95 # elif defined(__OS2__)
96 # if defined (__GNUC__) && __GNUC__ < 4
97 # /* Added support for GCC-EMX <v4.x */
98 # /* this is needed for XFree86/OS2 developement */
99 # /* F. Ambacher(anakor@snafu.de) 05.2008 */
100 # define SDLCALL _cdecl
102 # /* On other compilers on OS/2, we use the _System calling convention */
103 # /* to be compatible with every compiler */
104 # define SDLCALL _System
115 #elif !defined(__WINS__)
117 #define DECLSPEC __declspec(dllexport)
119 #endif /* __SYMBIAN32__ */
123 * Force structure packing at 4 byte alignment.
124 * This is necessary if the header is included in code which has structure
125 * packing set to an alternate value, say for loading structures from disk.
126 * The packing is reset to the previous value in close_code.h
128 #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
130 #pragma warning(disable: 4103)
133 #pragma nopackwarning
136 #elif (defined(__MWERKS__) && defined(__MACOS__))
137 #pragma options align=mac68k4byte
138 #pragma enumsalwaysint on
139 #endif /* Compiler needs structure packing set */
142 * @def SDL_INLINE_OKAY
143 * Set up compiler-specific options for inlining functions
145 #ifndef SDL_INLINE_OKAY
147 #define SDL_INLINE_OKAY
149 /* Add any special compiler-specific cases here */
150 #if defined(_MSC_VER) || defined(__BORLANDC__) || \
151 defined(__DMC__) || defined(__SC__) || \
152 defined(__WATCOMC__) || defined(__LCC__) || \
153 defined(__DECC) || defined(__EABI__)
155 #define __inline__ __inline
157 #define SDL_INLINE_OKAY
159 #if !defined(__MRC__) && !defined(_SGI_SOURCE)
161 #define __inline__ inline
163 #define SDL_INLINE_OKAY
164 #endif /* Not a funky compiler */
165 #endif /* Visual C++ */
167 #endif /* SDL_INLINE_OKAY */
171 * If inlining isn't supported, remove "__inline__", turning static
172 * inlined functions into static functions (resulting in code bloat
173 * in all files which include the offending header files)
175 #ifndef SDL_INLINE_OKAY
181 * Apparently this is needed by several Windows compilers
183 #if !defined(__MACH__)
188 #define NULL ((void *)0)
191 #endif /* ! Mac OS X - breaks precompiled headers */