Fix DLLEXPORT macro and move it's defination to separate file

This commit is contained in:
mittorn 2016-03-09 17:11:16 +06:00
parent f2ea272c02
commit 9fd279a974
14 changed files with 48 additions and 73 deletions

View File

@ -99,11 +99,6 @@ HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects. Export this function for the engine to use the studio renderer class to render objects.
==================== ====================
*/ */
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio ) extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{ {
if ( version != STUDIO_INTERFACE_VERSION ) if ( version != STUDIO_INTERFACE_VERSION )

View File

@ -972,7 +972,7 @@ HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects. Export this function for the engine to use the studio renderer class to render objects.
==================== ====================
*/ */
#define DLLEXPORT __declspec( dllexport )
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio ) extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{ {
if ( version != STUDIO_INTERFACE_VERSION ) if ( version != STUDIO_INTERFACE_VERSION )

View File

@ -29,13 +29,6 @@ extern "C"
#include <string.h> #include <string.h>
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
cl_enginefunc_t gEngfuncs; cl_enginefunc_t gEngfuncs;
CHud gHUD; CHud gHUD;
mobile_engfuncs_t *gMobileEngfuncs = NULL; mobile_engfuncs_t *gMobileEngfuncs = NULL;

View File

@ -31,13 +31,14 @@ typedef float vec_t;
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#include "util_vector.h" #include "util_vector.h"
#define EXPORT _declspec( dllexport )
#include "../engine/cdll_int.h" #include "../engine/cdll_int.h"
#include "../dlls/cdll_dll.h" #include "../dlls/cdll_dll.h"
#ifndef __MSC_VER
#define _cdecl #define _cdecl
#endif
#include "exportdef.h"
#include <string.h> #include <string.h>
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;

View File

@ -15,7 +15,7 @@
// //
// cl_util.h // cl_util.h
// //
#include "exportdef.h"
#include "cvardef.h" #include "cvardef.h"
#ifndef TRUE #ifndef TRUE

View File

@ -18,12 +18,6 @@
#include "demo_api.h" #include "demo_api.h"
#include <memory.h> #include <memory.h>
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
int g_demosniper = 0; int g_demosniper = 0;
int g_demosniperdamage = 0; int g_demosniperdamage = 0;
float g_demosniperorg[3]; float g_demosniperorg[3];
@ -104,4 +98,4 @@ void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" ); gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
break; break;
} }
} }

View File

@ -20,12 +20,6 @@
#include "pmtrace.h" #include "pmtrace.h"
#include "pm_shared.h" #include "pm_shared.h"
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
void Game_AddObjects( void ); void Game_AddObjects( void );

View File

@ -9,17 +9,11 @@
#define HUD_IFACEH #define HUD_IFACEH
#pragma once #pragma once
#ifdef _WIN32 #include "exportdef.h"
#define EXPORT _declspec( dllexport )
#define _DLLEXPORT __declspec( dllexport )
#else
#define EXPORT
#define _DLLEXPORT
#endif
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#include "wrect.h" #include "wrect.h"
#include "../engine/cdll_int.h" #include "../engine/cdll_int.h"
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
#endif #endif

View File

@ -17,9 +17,7 @@
#define ROLL 2 #define ROLL 2
#ifdef _WIN32 #ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else #else
#define DLLEXPORT
typedef struct point_s{ typedef struct point_s{
int x; int x;
int y; int y;

View File

@ -17,12 +17,6 @@
#include "cl_entity.h" #include "cl_entity.h"
#include "triangleapi.h" #include "triangleapi.h"
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
extern "C" extern "C"
{ {
void DLLEXPORT HUD_DrawNormalTriangles( void ); void DLLEXPORT HUD_DrawNormalTriangles( void );
@ -125,4 +119,4 @@ void DLLEXPORT HUD_DrawTransparentTriangles( void )
#if defined( TEST_IT ) #if defined( TEST_IT )
// Draw_Triangles(); // Draw_Triangles();
#endif #endif
} }

View File

@ -51,11 +51,7 @@ CBaseEntity
// C functions for external declarations that call the appropriate C++ methods // C functions for external declarations that call the appropriate C++ methods
#ifdef _WIN32 #include "exportdef.h"
#define EXPORT _declspec( dllexport )
#else
#define EXPORT /* */
#endif
extern "C" EXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); extern "C" EXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion );
extern "C" EXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); extern "C" EXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion );
@ -373,15 +369,15 @@ public:
#else #else
#define SetThink( a ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (a) #define SetThink( a ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (a)
#define SetTouch( a ) m_pfnTouch = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (a) #define SetTouch( a ) m_pfnTouch = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (a)
#define SetUse( a ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (a) #define SetUse( a ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (a)
#define SetBlocked( a ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (a) #define SetBlocked( a ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (a)
#define ResetThink( ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (NULL) #define ResetThink( ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (NULL)
#define ResetTouch( ) m_pfnTouch = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL) #define ResetTouch( ) m_pfnTouch = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL)
#define ResetUse( ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (NULL) #define ResetUse( ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (NULL)
#define ResetBlocked( ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL) #define ResetBlocked( ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL)
#endif #endif
@ -557,8 +553,8 @@ public:
// the button will be allowed to operate. Otherwise, it will be // the button will be allowed to operate. Otherwise, it will be
// deactivated. // deactivated.
}; };
#define SetMoveDone( a ) m_pfnCallWhenMoveDone = static_cast <void (CBaseToggle::*)(void)> (a) #define SetMoveDone( a ) m_pfnCallWhenMoveDone = static_cast <void (CBaseToggle::*)(void)> (a)
// people gib if their health is <= this at the time of death // people gib if their health is <= this at the time of death

18
dlls/exportdef.h Normal file
View File

@ -0,0 +1,18 @@
#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

View File

@ -47,7 +47,10 @@ BOOL WINAPI DllMain(
return TRUE; return TRUE;
} }
void DLLEXPORT GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) extern "C" void DLLEXPORT GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) __attribute__((__stdcall__)) ;
extern "C" void DLLEXPORT GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{ {
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals; gpGlobals = pGlobals;

View File

@ -27,9 +27,9 @@
#include "physcallback.h" #include "physcallback.h"
#endif #endif
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file
extern globalvars_t *gpGlobals; extern globalvars_t *gpGlobals;
@ -92,13 +92,8 @@ typedef int BOOL;
// This is the glue that hooks .MAP entity class names to our CPP classes // This is the glue that hooks .MAP entity class names to our CPP classes
// The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress() // The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress()
// The function is used to intialize / allocate the object for the entity // The function is used to intialize / allocate the object for the entity
#ifdef _WIN32
#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) \ #define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) extern "C" EXPORT void mapClassName( entvars_t *pev ); void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); }
extern "C" _declspec( dllexport ) void mapClassName( entvars_t *pev ); \
void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); }
#else
#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) extern "C" void mapClassName( entvars_t *pev ); void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); }
#endif
// //