From 0a331ca9a416f5328b0592239c848095d4e6ce38 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 31 Aug 2020 20:21:43 +0300 Subject: [PATCH] cl_dll: add more crossplatform typedefs, defines --- cl_dll/cl_util.h | 9 ++++----- common/port.h | 1 + dlls/exportdef.h | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 dlls/exportdef.h diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index f619204..e2cf760 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -17,9 +17,8 @@ // #include "cvardef.h" - -#define EXPORT _declspec( dllexport ) -#define DLLEXPORT __declspec( dllexport ) +#include "port.h" +#include "exportdef.h" #ifndef TRUE #define TRUE 1 @@ -135,14 +134,14 @@ extern "C" void DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, c #define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \ { \ - return gHUD.##y.MsgFunc_##x(pszName, iSize, pbuf ); \ + return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \ } #define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y ); #define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \ { \ - gHUD.##y.UserCmd_##x( ); \ + gHUD.y.UserCmd_##x( ); \ } #define SPR_Set (*gEngfuncs.pfnSPR_Set) diff --git a/common/port.h b/common/port.h index 33b4e2d..6b9a351 100644 --- a/common/port.h +++ b/common/port.h @@ -87,6 +87,7 @@ GNU General Public License for more details. typedef unsigned int ULONG; typedef int WPARAM; typedef unsigned int LPARAM; + typedef int BOOL; typedef void* HANDLE; typedef void* HMODULE; diff --git a/dlls/exportdef.h b/dlls/exportdef.h new file mode 100644 index 0000000..363d8d1 --- /dev/null +++ b/dlls/exportdef.h @@ -0,0 +1,19 @@ +#pragma once +#ifndef EXPORTDEF_H +#define EXPORTDEF_H +#if defined _WIN32 || defined __CYGWIN__ + #ifdef __GNUC__ + #define EXPORT __attribute__ ((dllexport)) + #else + #define EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax. + #endif +#else + #if __GNUC__ >= 4 + #define EXPORT __attribute__ ((visibility ("default"))) + #else + #define EXPORT + #endif +#endif +#define DLLEXPORT EXPORT +#define _DLLEXPORT EXPORT +#endif // EXPORTDEF_H