From d2097aadcb55963b0702f4dec374ea0f4603fae0 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 10 Feb 2019 12:44:16 -0500 Subject: [PATCH] Clean up multi-include magic. --- src/SDL12_compat.c | 10 +--------- src/SDL20_syms.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c index 6d4c56f4f..0275f73d1 100644 --- a/src/SDL12_compat.c +++ b/src/SDL12_compat.c @@ -57,19 +57,15 @@ #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \ SDL20_SYM(rc,fn,params,args,ret) #include "SDL20_syms.h" -#undef SDL20_SYM_PASSTHROUGH -#undef SDL20_SYM +/* this doesn't get handled in SDL20_syms.h because it uses varargs. */ typedef int (SDLCALL *SDL20_SetError_t)(const char *fmt, ...); static SDL20_SetError_t SDL20_SetError = NULL; /* Things that _should_ be binary compatible pass right through... */ -#define SDL20_SYM(rc,fn,params,args,ret) #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \ DECLSPEC rc SDLCALL SDL_##fn params { ret SDL20_##fn args; } #include "SDL20_syms.h" -#undef SDL20_SYM_PASSTHROUGH -#undef SDL20_SYM /* these are macros (etc) in the SDL headers, so make our own. */ @@ -446,8 +442,6 @@ UnloadSDL20(void) #define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = NULL; #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret) #include "SDL20_syms.h" - #undef SDL20_SYM_PASSTHROUGH - #undef SDL20_SYM SDL20_SetError = NULL; CloseSDL20Library(); } @@ -462,8 +456,6 @@ LoadSDL20(void) #define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = (SDL20_##fn##_t) LoadSDL20Symbol("SDL_" #fn, &okay); #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret) #include "SDL20_syms.h" - #undef SDL20_SYM_PASSTHROUGH - #undef SDL20_SYM SDL20_SetError = (SDL20_SetError_t) LoadSDL20Symbol("SDL_SetError", &okay); if (!okay) UnloadSDL20(); diff --git a/src/SDL20_syms.h b/src/SDL20_syms.h index 679d9ae81..8eaeda22d 100644 --- a/src/SDL20_syms.h +++ b/src/SDL20_syms.h @@ -21,6 +21,14 @@ /* don't #pragma once this file, it gets #included multiple times! */ +#ifndef SDL20_SYM +#define SDL20_SYM(rc,fn,params,args,ret) +#endif + +#ifndef SDL20_SYM_PASSTHROUGH +#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) +#endif + SDL20_SYM(int,Init,(Uint32 a),(a),return) SDL20_SYM(int,InitSubSystem,(Uint32 a),(a),return) SDL20_SYM(Uint32,WasInit,(Uint32 a),(a),return) @@ -224,5 +232,8 @@ SDL20_SYM_PASSTHROUGH(char *,iconv_string,(const char *a, const char *b, const c SDL20_SYM(int,setenv,(const char *a, const char *b, int c),(a,b,c),return) SDL20_SYM(int,atoi,(const char *a),(a),return) +#undef SDL20_SYM +#undef SDL20_SYM_PASSTHROUGH + /* vi: set ts=4 sw=4 expandtab: */