Skip to content

Latest commit

 

History

History
179 lines (166 loc) · 4.64 KB

begin_code.h

File metadata and controls

179 lines (166 loc) · 4.64 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
# ifdef BUILD_SDL
Mar 22, 2006
Mar 22, 2006
62
# define DECLSPEC __declspec(dllexport)
Nov 23, 2005
Nov 23, 2005
63
# else
Mar 22, 2006
Mar 22, 2006
64
65
# define DECLSPEC
# endif
Nov 23, 2005
Nov 23, 2005
66
# else
Mar 23, 2006
Mar 23, 2006
67
# if defined(__GNUC__) && __GNUC__ >= 4
Mar 22, 2006
Mar 22, 2006
68
69
70
71
# define DECLSPEC __attribute__ ((visibility("default")))
# else
# define DECLSPEC
# endif
Nov 23, 2005
Nov 23, 2005
72
# endif
Apr 26, 2001
Apr 26, 2001
73
74
#endif
Sep 21, 2009
Sep 21, 2009
75
76
77
78
/**
* @def SDLCALL
* By default SDL uses the C calling convention
*/
Apr 11, 2002
Apr 11, 2002
79
#ifndef SDLCALL
Sep 14, 2009
Sep 14, 2009
80
81
82
# if defined(__WIN32__) && !defined(__GNUC__)
# define SDLCALL __cdecl
# elif defined(__OS2__)
Mar 24, 2018
Mar 24, 2018
83
84
85
86
/* But on OS/2, we use the _System calling convention */
/* to be compatible with every compiler */
# if defined (__GNUC__) && !defined(_System)
# define _System /* For compatibility with old GCC/EMX */
Sep 14, 2009
Sep 14, 2009
87
# endif
Mar 24, 2018
Mar 24, 2018
88
# define SDLCALL _System
Sep 14, 2009
Sep 14, 2009
89
90
91
# else
# define SDLCALL
# endif
Apr 11, 2002
Apr 11, 2002
92
93
#endif /* SDLCALL */
Sep 11, 2001
Sep 11, 2001
94
#ifdef __SYMBIAN32__
Jun 24, 2007
Jun 24, 2007
95
#ifndef EKA2
Sep 11, 2001
Sep 11, 2001
96
97
#undef DECLSPEC
#define DECLSPEC
Jun 24, 2007
Jun 24, 2007
98
99
100
#elif !defined(__WINS__)
#undef DECLSPEC
#define DECLSPEC __declspec(dllexport)
Aug 5, 2007
Aug 5, 2007
101
102
#endif /* !EKA2 */
#endif /* __SYMBIAN32__ */
Sep 11, 2001
Sep 11, 2001
103
Sep 21, 2009
Sep 21, 2009
104
105
106
107
108
109
/**
* @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
110
*/
Feb 28, 2002
Feb 28, 2002
111
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
Apr 26, 2001
Apr 26, 2001
112
113
114
115
116
117
#ifdef _MSC_VER
#pragma warning(disable: 4103)
#endif
#ifdef __BORLANDC__
#pragma nopackwarning
#endif
Jan 9, 2012
Jan 9, 2012
118
119
120
121
#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
122
#pragma pack(push,4)
Jan 9, 2012
Jan 9, 2012
123
#endif
Feb 21, 2006
Feb 21, 2006
124
#elif (defined(__MWERKS__) && defined(__MACOS__))
Sep 23, 2001
Sep 23, 2001
125
126
#pragma options align=mac68k4byte
#pragma enumsalwaysint on
Apr 26, 2001
Apr 26, 2001
127
128
#endif /* Compiler needs structure packing set */
Sep 21, 2009
Sep 21, 2009
129
130
131
132
/**
* @def SDL_INLINE_OKAY
* Set up compiler-specific options for inlining functions
*/
Apr 26, 2001
Apr 26, 2001
133
134
135
136
137
#ifndef SDL_INLINE_OKAY
#ifdef __GNUC__
#define SDL_INLINE_OKAY
#else
/* Add any special compiler-specific cases here */
Feb 28, 2002
Feb 28, 2002
138
139
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
defined(__DMC__) || defined(__SC__) || \
Jan 2, 2005
Jan 2, 2005
140
defined(__WATCOMC__) || defined(__LCC__) || \
Jun 24, 2007
Jun 24, 2007
141
defined(__DECC) || defined(__EABI__)
Feb 28, 2002
Feb 28, 2002
142
#ifndef __inline__
Jul 2, 2001
Jul 2, 2001
143
#define __inline__ __inline
Feb 28, 2002
Feb 28, 2002
144
#endif
Jul 2, 2001
Jul 2, 2001
145
146
147
#define SDL_INLINE_OKAY
#else
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
Jun 15, 2007
Jun 15, 2007
148
#ifndef __inline__
Apr 26, 2001
Apr 26, 2001
149
#define __inline__ inline
Jun 15, 2007
Jun 15, 2007
150
#endif
Apr 26, 2001
Apr 26, 2001
151
152
#define SDL_INLINE_OKAY
#endif /* Not a funky compiler */
Jul 2, 2001
Jul 2, 2001
153
#endif /* Visual C++ */
Apr 26, 2001
Apr 26, 2001
154
155
156
#endif /* GNU C */
#endif /* SDL_INLINE_OKAY */
Sep 21, 2009
Sep 21, 2009
157
158
159
160
161
162
/**
* @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
163
164
165
166
#ifndef SDL_INLINE_OKAY
#define __inline__
#endif
Sep 21, 2009
Sep 21, 2009
167
168
169
170
/**
* @def NULL
* Apparently this is needed by several Windows compilers
*/
Apr 13, 2002
Apr 13, 2002
171
#if !defined(__MACH__)
Feb 28, 2002
Feb 28, 2002
172
173
174
175
176
177
178
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif /* NULL */
Apr 13, 2006
Apr 13, 2006
179
#endif /* ! Mac OS X - breaks precompiled headers */