| 1 | /* |
| 2 | SDL - Simple DirectMedia Layer |
| 3 | Copyright (C) 1997-2010 Sam Lantinga |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 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 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | |
| 19 | Sam Lantinga |
| 20 | slouken@libsdl.org |
| 21 | */ |
| 22 | |
| 23 | /** |
| 24 | * \file begin_code.h |
| 25 | * |
| 26 | * This file sets things up for C dynamic library function definitions, |
| 27 | * static inlined functions, and structures aligned at 4-byte alignment. |
| 28 | * If you don't like ugly C preprocessor code, don't look at this file. :) |
| 29 | */ |
| 30 | |
| 31 | /* This shouldn't be nested -- included it around code only. */ |
| 32 | #ifdef _begin_code_h |
| 33 | #error Nested inclusion of begin_code.h |
| 34 | #endif |
| 35 | #define _begin_code_h |
| 36 | |
| 37 | /* Some compilers use a special export keyword */ |
| 38 | #ifndef DECLSPEC |
| 39 | # if defined(__BEOS__) || defined(__HAIKU__) |
| 40 | # if defined(__GNUC__) |
| 41 | # define DECLSPEC __declspec(dllexport) |
| 42 | # else |
| 43 | # define DECLSPEC __declspec(export) |
| 44 | # endif |
| 45 | # elif defined(__WIN32__) |
| 46 | # ifdef __BORLANDC__ |
| 47 | # ifdef BUILD_SDL |
| 48 | # define DECLSPEC |
| 49 | # else |
| 50 | # define DECLSPEC __declspec(dllimport) |
| 51 | # endif |
| 52 | # else |
| 53 | # define DECLSPEC __declspec(dllexport) |
| 54 | # endif |
| 55 | # else |
| 56 | # if defined(__GNUC__) && __GNUC__ >= 4 |
| 57 | # define DECLSPEC __attribute__ ((visibility("default"))) |
| 58 | # else |
| 59 | # define DECLSPEC |
| 60 | # endif |
| 61 | # endif |
| 62 | #endif |
| 63 | |
| 64 | /* By default SDL uses the C calling convention */ |
| 65 | #ifndef SDLCALL |
| 66 | #if defined(__WIN32__) && !defined(__GNUC__) |
| 67 | #define SDLCALL __cdecl |
| 68 | #else |
| 69 | #define SDLCALL |
| 70 | #endif |
| 71 | #endif /* SDLCALL */ |
| 72 | |
| 73 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ |
| 74 | #ifdef __SYMBIAN32__ |
| 75 | #undef DECLSPEC |
| 76 | #define DECLSPEC |
| 77 | #endif /* __SYMBIAN32__ */ |
| 78 | |
| 79 | /* Force structure packing at 4 byte alignment. |
| 80 | This is necessary if the header is included in code which has structure |
| 81 | packing set to an alternate value, say for loading structures from disk. |
| 82 | The packing is reset to the previous value in close_code.h |
| 83 | */ |
| 84 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) |
| 85 | #ifdef _MSC_VER |
| 86 | #pragma warning(disable: 4103) |
| 87 | #endif |
| 88 | #ifdef __BORLANDC__ |
| 89 | #pragma nopackwarning |
| 90 | #endif |
| 91 | #pragma pack(push,4) |
| 92 | #endif /* Compiler needs structure packing set */ |
| 93 | |
| 94 | /* Set up compiler-specific options for inlining functions */ |
| 95 | #ifndef SDL_INLINE_OKAY |
| 96 | #ifdef __GNUC__ |
| 97 | #define SDL_INLINE_OKAY |
| 98 | #else |
| 99 | /* Add any special compiler-specific cases here */ |
| 100 | #if defined(_MSC_VER) || defined(__BORLANDC__) || \ |
| 101 | defined(__DMC__) || defined(__SC__) || \ |
| 102 | defined(__WATCOMC__) || defined(__LCC__) || \ |
| 103 | defined(__DECC) |
| 104 | #ifndef __inline__ |
| 105 | #define __inline__ __inline |
| 106 | #endif |
| 107 | #define SDL_INLINE_OKAY |
| 108 | #else |
| 109 | #if !defined(__MRC__) && !defined(_SGI_SOURCE) |
| 110 | #ifndef __inline__ |
| 111 | #define __inline__ inline |
| 112 | #endif |
| 113 | #define SDL_INLINE_OKAY |
| 114 | #endif /* Not a funky compiler */ |
| 115 | #endif /* Visual C++ */ |
| 116 | #endif /* GNU C */ |
| 117 | #endif /* SDL_INLINE_OKAY */ |
| 118 | |
| 119 | /* If inlining isn't supported, remove "__inline__", turning static |
| 120 | inlined functions into static functions (resulting in code bloat |
| 121 | in all files which include the offending header files) |
| 122 | */ |
| 123 | #ifndef SDL_INLINE_OKAY |
| 124 | #define __inline__ |
| 125 | #endif |
| 126 | |
| 127 | /* Apparently this is needed by several Windows compilers */ |
| 128 | #if !defined(__MACH__) |
| 129 | #ifndef NULL |
| 130 | #ifdef __cplusplus |
| 131 | #define NULL 0 |
| 132 | #else |
| 133 | #define NULL ((void *)0) |
| 134 | #endif |
| 135 | #endif /* NULL */ |
| 136 | #endif /* ! Mac OS X - breaks precompiled headers */ |