Miguel Ruiz / SDL_lib

Dependents:   H261_encoder

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers begin_code.h Source File

begin_code.h

Go to the documentation of this file.
00001 /*
00002   Simple DirectMedia Layer
00003   Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
00004 
00005   This software is provided 'as-is', without any express or implied
00006   warranty.  In no event will the authors be held liable for any damages
00007   arising from the use of this software.
00008 
00009   Permission is granted to anyone to use this software for any purpose,
00010   including commercial applications, and to alter it and redistribute it
00011   freely, subject to the following restrictions:
00012 
00013   1. The origin of this software must not be misrepresented; you must not
00014      claim that you wrote the original software. If you use this software
00015      in a product, an acknowledgment in the product documentation would be
00016      appreciated but is not required.
00017   2. Altered source versions must be plainly marked as such, and must not be
00018      misrepresented as being the original software.
00019   3. This notice may not be removed or altered from any source distribution.
00020 */
00021 
00022 /**
00023  *  \file begin_code.h
00024  *
00025  *  This file sets things up for C dynamic library function definitions,
00026  *  static inlined functions, and structures aligned at 4-byte alignment.
00027  *  If you don't like ugly C preprocessor code, don't look at this file. :)
00028  */
00029 
00030 /* This shouldn't be nested -- included it around code only. */
00031 #ifdef _begin_code_h
00032 #error Nested inclusion of begin_code.h
00033 #endif
00034 #define _begin_code_h
00035 
00036 #ifndef SDL_DEPRECATED
00037 #  if (__GNUC__ >= 4)  /* technically, this arrived in gcc 3.1, but oh well. */
00038 #    define SDL_DEPRECATED __attribute__((deprecated))
00039 #  else
00040 #    define SDL_DEPRECATED
00041 #  endif
00042 #endif
00043 
00044 /* Some compilers use a special export keyword */
00045 #ifndef DECLSPEC
00046 # if defined(__WIN32__)
00047 #  ifdef __BORLANDC__
00048 #   ifdef BUILD_SDL
00049 #    define DECLSPEC
00050 #   else
00051 #    define DECLSPEC    __declspec(dllimport)
00052 #   endif
00053 #  else
00054 #   define DECLSPEC __declspec(dllexport)
00055 #  endif
00056 # else
00057 #  if defined(__GNUC__) && __GNUC__ >= 4
00058 #   define DECLSPEC __attribute__ ((visibility("default")))
00059 #  elif defined(__GNUC__) && __GNUC__ >= 2
00060 #   define DECLSPEC __declspec(dllexport)
00061 #  else
00062 #   define DECLSPEC
00063 #  endif
00064 # endif
00065 #endif
00066 
00067 /* By default SDL uses the C calling convention */
00068 #ifndef SDLCALL
00069 #if defined(__WIN32__) && !defined(__GNUC__)
00070 #define SDLCALL __cdecl
00071 #else
00072 #define SDLCALL
00073 #endif
00074 #endif /* SDLCALL */
00075 
00076 /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
00077 #ifdef __SYMBIAN32__
00078 #undef DECLSPEC
00079 #define DECLSPEC
00080 #endif /* __SYMBIAN32__ */
00081 
00082 /* Force structure packing at 4 byte alignment.
00083    This is necessary if the header is included in code which has structure
00084    packing set to an alternate value, say for loading structures from disk.
00085    The packing is reset to the previous value in close_code.h
00086  */
00087 #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
00088 #ifdef _MSC_VER
00089 #pragma warning(disable: 4103)
00090 #endif
00091 #ifdef __BORLANDC__
00092 #pragma nopackwarning
00093 #endif
00094 #ifdef _M_X64
00095 /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
00096 #pragma pack(push,8)
00097 #else
00098 #pragma pack(push,4)
00099 #endif
00100 #endif /* Compiler needs structure packing set */
00101 
00102 #ifndef SDL_INLINE
00103 #if defined(__GNUC__)
00104 #define SDL_INLINE __inline__
00105 #elif defined(_MSC_VER) || defined(__BORLANDC__) || \
00106       defined(__DMC__) || defined(__SC__) || \
00107       defined(__WATCOMC__) || defined(__LCC__) || \
00108       defined(__DECC)
00109 #define SDL_INLINE __inline
00110 #ifndef __inline__
00111 #define __inline__ __inline
00112 #endif
00113 #else
00114 #define SDL_INLINE inline
00115 #ifndef __inline__
00116 #define __inline__ inline
00117 #endif
00118 #endif
00119 #endif /* SDL_INLINE not defined */
00120 
00121 #ifndef SDL_FORCE_INLINE
00122 #if defined(_MSC_VER)
00123 #define SDL_FORCE_INLINE __forceinline
00124 #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
00125 #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
00126 #else
00127 #define SDL_FORCE_INLINE static SDL_INLINE
00128 #endif
00129 #endif /* SDL_FORCE_INLINE not defined */
00130 
00131 /* Apparently this is needed by several Windows compilers */
00132 #if !defined(__MACH__)
00133 #ifndef NULL
00134 #ifdef __cplusplus
00135 #define NULL 0
00136 #else
00137 #define NULL ((void *)0)
00138 #endif
00139 #endif /* NULL */
00140 #endif /* ! Mac OS X - breaks precompiled headers */