Skip to content

Latest commit

 

History

History
196 lines (183 loc) · 5.11 KB

begin_code.h

File metadata and controls

196 lines (183 loc) · 5.11 KB
 
Apr 26, 2001
Apr 26, 2001
1
2
/*
SDL - Simple DirectMedia Layer
Dec 31, 2011
Dec 31, 2011
3
Copyright (C) 1997-2012 Sam Lantinga
Apr 26, 2001
Apr 26, 2001
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
Dec 14, 2001
Dec 14, 2001
20
slouken@libsdl.org
Apr 26, 2001
Apr 26, 2001
21
22
*/
Sep 21, 2009
Sep 21, 2009
23
24
25
26
27
28
/**
* @file begin_code.h
* This file sets things up for C dynamic library function definitions,
* static inlined functions, and structures aligned at 4-byte alignment.
* If you don't like ugly C preprocessor code, don't look at this file. :)
*/
Apr 26, 2001
Apr 26, 2001
29
Sep 21, 2009
Sep 21, 2009
30
31
32
33
/**
* @file begin_code.h
* This shouldn't be nested -- included it around code only.
*/
Apr 26, 2001
Apr 26, 2001
34
35
36
37
38
#ifdef _begin_code_h
#error Nested inclusion of begin_code.h
#endif
#define _begin_code_h
Sep 21, 2009
Sep 21, 2009
39
40
41
42
/**
* @def DECLSPEC
* Some compilers use a special export keyword
*/
Apr 26, 2001
Apr 26, 2001
43
#ifndef DECLSPEC
Mar 17, 2009
Mar 17, 2009
44
# if defined(__BEOS__) || defined(__HAIKU__)
Apr 26, 2001
Apr 26, 2001
45
# if defined(__GNUC__)
Sep 19, 2010
Sep 19, 2010
46
# define DECLSPEC
Apr 26, 2001
Apr 26, 2001
47
48
49
# else
# define DECLSPEC __declspec(export)
# endif
Mar 22, 2006
Mar 22, 2006
50
# elif defined(__WIN32__)
Feb 13, 2002
Feb 13, 2002
51
52
# ifdef __BORLANDC__
# ifdef BUILD_SDL
Jun 28, 2003
Jun 28, 2003
53
# define DECLSPEC
Feb 13, 2002
Feb 13, 2002
54
# else
Mar 22, 2006
Mar 22, 2006
55
# define DECLSPEC __declspec(dllimport)
Feb 13, 2002
Feb 13, 2002
56
57
58
59
# endif
# else
# define DECLSPEC __declspec(dllexport)
# endif
Mar 22, 2006
Mar 22, 2006
60
# elif defined(__OS2__)
Nov 23, 2005
Nov 23, 2005
61
62
# ifdef __WATCOMC__
# ifdef BUILD_SDL
Mar 22, 2006
Mar 22, 2006
63
# define DECLSPEC __declspec(dllexport)
Nov 23, 2005
Nov 23, 2005
64
# else
Mar 22, 2006
Mar 22, 2006
65
66
# define DECLSPEC
# endif
Sep 14, 2009
Sep 14, 2009
67
68
69
70
71
72
73
74
75
# elif defined (__GNUC__) && __GNUC__ < 4
# /* Added support for GCC-EMX <v4.x */
# /* this is needed for XFree86/OS2 developement */
# /* F. Ambacher(anakor@snafu.de) 05.2008 */
# ifdef BUILD_SDL
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC
# endif
Nov 23, 2005
Nov 23, 2005
76
77
78
79
# else
# define DECLSPEC
# endif
# else
Mar 23, 2006
Mar 23, 2006
80
# if defined(__GNUC__) && __GNUC__ >= 4
Mar 22, 2006
Mar 22, 2006
81
82
83
84
# define DECLSPEC __attribute__ ((visibility("default")))
# else
# define DECLSPEC
# endif
Nov 23, 2005
Nov 23, 2005
85
# endif
Apr 26, 2001
Apr 26, 2001
86
87
#endif
Sep 21, 2009
Sep 21, 2009
88
89
90
91
/**
* @def SDLCALL
* By default SDL uses the C calling convention
*/
Apr 11, 2002
Apr 11, 2002
92
#ifndef SDLCALL
Sep 14, 2009
Sep 14, 2009
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# if defined(__WIN32__) && !defined(__GNUC__)
# define SDLCALL __cdecl
# elif defined(__OS2__)
# if defined (__GNUC__) && __GNUC__ < 4
# /* Added support for GCC-EMX <v4.x */
# /* this is needed for XFree86/OS2 developement */
# /* F. Ambacher(anakor@snafu.de) 05.2008 */
# define SDLCALL _cdecl
# else
# /* On other compilers on OS/2, we use the _System calling convention */
# /* to be compatible with every compiler */
# define SDLCALL _System
# endif
# else
# define SDLCALL
# endif
Apr 11, 2002
Apr 11, 2002
109
110
#endif /* SDLCALL */
Sep 11, 2001
Sep 11, 2001
111
#ifdef __SYMBIAN32__
Jun 24, 2007
Jun 24, 2007
112
#ifndef EKA2
Sep 11, 2001
Sep 11, 2001
113
114
#undef DECLSPEC
#define DECLSPEC
Jun 24, 2007
Jun 24, 2007
115
116
117
#elif !defined(__WINS__)
#undef DECLSPEC
#define DECLSPEC __declspec(dllexport)
Aug 5, 2007
Aug 5, 2007
118
119
#endif /* !EKA2 */
#endif /* __SYMBIAN32__ */
Sep 11, 2001
Sep 11, 2001
120
Sep 21, 2009
Sep 21, 2009
121
122
123
124
125
126
/**
* @file begin_code.h
* Force structure packing at 4 byte alignment.
* This is necessary if the header is included in code which has structure
* packing set to an alternate value, say for loading structures from disk.
* The packing is reset to the previous value in close_code.h
Apr 26, 2001
Apr 26, 2001
127
*/
Feb 28, 2002
Feb 28, 2002
128
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
Apr 26, 2001
Apr 26, 2001
129
130
131
132
133
134
#ifdef _MSC_VER
#pragma warning(disable: 4103)
#endif
#ifdef __BORLANDC__
#pragma nopackwarning
#endif
Jan 9, 2012
Jan 9, 2012
135
136
137
138
#ifdef _M_X64
/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
#pragma pack(push,8)
#else
Sep 23, 2001
Sep 23, 2001
139
#pragma pack(push,4)
Jan 9, 2012
Jan 9, 2012
140
#endif
Feb 21, 2006
Feb 21, 2006
141
#elif (defined(__MWERKS__) && defined(__MACOS__))
Sep 23, 2001
Sep 23, 2001
142
143
#pragma options align=mac68k4byte
#pragma enumsalwaysint on
Apr 26, 2001
Apr 26, 2001
144
145
#endif /* Compiler needs structure packing set */
Sep 21, 2009
Sep 21, 2009
146
147
148
149
/**
* @def SDL_INLINE_OKAY
* Set up compiler-specific options for inlining functions
*/
Apr 26, 2001
Apr 26, 2001
150
151
152
153
154
#ifndef SDL_INLINE_OKAY
#ifdef __GNUC__
#define SDL_INLINE_OKAY
#else
/* Add any special compiler-specific cases here */
Feb 28, 2002
Feb 28, 2002
155
156
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
defined(__DMC__) || defined(__SC__) || \
Jan 2, 2005
Jan 2, 2005
157
defined(__WATCOMC__) || defined(__LCC__) || \
Jun 24, 2007
Jun 24, 2007
158
defined(__DECC) || defined(__EABI__)
Feb 28, 2002
Feb 28, 2002
159
#ifndef __inline__
Jul 2, 2001
Jul 2, 2001
160
#define __inline__ __inline
Feb 28, 2002
Feb 28, 2002
161
#endif
Jul 2, 2001
Jul 2, 2001
162
163
164
#define SDL_INLINE_OKAY
#else
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
Jun 15, 2007
Jun 15, 2007
165
#ifndef __inline__
Apr 26, 2001
Apr 26, 2001
166
#define __inline__ inline
Jun 15, 2007
Jun 15, 2007
167
#endif
Apr 26, 2001
Apr 26, 2001
168
169
#define SDL_INLINE_OKAY
#endif /* Not a funky compiler */
Jul 2, 2001
Jul 2, 2001
170
#endif /* Visual C++ */
Apr 26, 2001
Apr 26, 2001
171
172
173
#endif /* GNU C */
#endif /* SDL_INLINE_OKAY */
Sep 21, 2009
Sep 21, 2009
174
175
176
177
178
179
/**
* @def __inline__
* If inlining isn't supported, remove "__inline__", turning static
* inlined functions into static functions (resulting in code bloat
* in all files which include the offending header files)
*/
Apr 26, 2001
Apr 26, 2001
180
181
182
183
#ifndef SDL_INLINE_OKAY
#define __inline__
#endif
Sep 21, 2009
Sep 21, 2009
184
185
186
187
/**
* @def NULL
* Apparently this is needed by several Windows compilers
*/
Apr 13, 2002
Apr 13, 2002
188
#if !defined(__MACH__)
Feb 28, 2002
Feb 28, 2002
189
190
191
192
193
194
195
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif /* NULL */
Apr 13, 2006
Apr 13, 2006
196
#endif /* ! Mac OS X - breaks precompiled headers */