Read it here :
Guide : Exporting functions in Half-life mods
This document deals with strange declaration of GiveFnptrsToDll()
and various macros and function keywords used in HL SDK, Metamod and most of todays bots/mods for Half-life.
You have now detailed guide which can teach you :
- What are all those extern "C", EXPORT, DLLEXPORT, WINAPI, __stdcall and _declspec(dllexport) symbols ?
- Pesky name-decoration
- Why do you must have .def file in your bot ?
- How it is possible to not to use .def file under MSVC and have working bot
Wanna know more ?
I will include here the most important part :
How it is possible to not to use .def file under MSVC and have working bot
If you are already using .def file :
- delete .def file used in MSVC
- remove all references to your .def file from your project
Change GiveFnptrsToDll()s definition to :
Code:
#if defined _WIN32
#pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#pragma comment(linker, "/SECTION:.data,RW")
#endif
#ifndef __linux__
extern "C" void __stdcall GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine,globalvars_t *pGlobals)
#else
extern "C" void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine,globalvars_t *pGlobals)
#endif
{
...
}
Advantages of my approach :
- whole export procedure is controlled in one file, no need to create special .def file just for one export
- fully compatible with HL SDKs approach. (Including making GiveFnptrsToDll first on export list and explicitly defining READ and WRITE attribute for .data section)
Note that this solution is for MSVC and linux. You have to include additional code for Borland or MingW32 to export it
(But you had to do it also in old approach, hadn't you ?)
And for experienced bot coders, I have
Comparing declarations of GiveFnptrsToDll() and Server_GetBlendingInterface() in bots. They may or may not find there something useful. But it should be useful at least for Pierre and Botman, because it seems they have bugs in their bots
(Botmans HPB bot template and Pierres templates)
.