View Full Version : Why does WINAPI work on linux?
sPlOrYgOn
17-04-2004, 07:08
void WINAPI GiveFnptrsToDll (enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
{
// get the engine functions from the engine...
memcpy (&g_engfuncs, pengfuncsFromEngine, sizeof (enginefuncs_t));
gpGlobals = pGlobals;
}
I found that in the podbot2.6mm source code and it doesn't have #ifndef __linux__ or anything like that.
Why does this work?
DLLMain has #ifndef __linux__ around it...
You'll find this in other bots source too, e.g. joebot and yapb.
I never verified this but I assume it's defined somewhere in the HL SDK and the OS check is done during the definition of WINAPI.
@$3.1415rin
17-04-2004, 10:40
this was in the namefunc.cpp right ?
that file is only linked with the rest on windows, on linux it doesnt appear in the makefile ( if I remember that one right )
sPlOrYgOn
17-04-2004, 10:48
no it's the dll.cpp in podbot..
and it has the metamod functions and DLLMain and other things. #ifndef __linux__
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
// Required DLL entry point
return (TRUE);
}
#endif
void WINAPI GiveFnptrsToDll (enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
{
// get the engine functions from the engine...
memcpy (&g_engfuncs, pengfuncsFromEngine, sizeof (enginefuncs_t));
gpGlobals = pGlobals;
}
they're right next to each other but one is compiled in linux and one isn't. Yet podbot still compile on linux without any problems...
@$3.1415rin
17-04-2004, 11:01
ok, nothing like that in the namefunc, right ...
if that's there in the dll.cpp in some bots ( don't have such a bot on my hd atm ) I think that must be some calling convention definition, maybe solved to _cdecl, dunno. maybe you can try to get it using the browse function of your IDE, if that's supported.
from metamod/osdep.h:
// Windows uses "__declspec(dllexport)" to mark functions in the DLL that
// should be visible/callable externally.
//
// It also apparently requires WINAPI for GiveFnptrsToDll().
//
// See doc/notes_windows_coding for more information..
// Attributes to specify an "exported" function, visible from outside the
// DLL.
#undef DLLEXPORT
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
// WINAPI should be provided in the windows compiler headers.
// It's usually defined to something like "__stdcall".
#elif defined(linux)
#define DLLEXPORT /* */
#define WINAPI /* */
#endif /* linux */
sPlOrYgOn
17-04-2004, 18:52
thanks
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.