rehlds / ReGameDLL_CS

Enhanced server-side GameDLL for Counter-Strike 1.6 (and CS: Condition Zero), offering new features and fixes.
https://rehlds.dev/docs/regamedll-cs
GNU General Public License v3.0
590 stars 203 forks source link

Sys_GetProcAddress - Build failed on MinGW32 #1003

Open SmileYzn opened 2 months ago

SmileYzn commented 2 months ago

Sys_GetProcAddress - Build failed on MinGW32

https://github.com/s1lentq/ReGameDLL_CS/blob/dc16b12d7976f03d20b81f9a2491ee7dddbb9b8e/regamedll/public/interface.cpp#L110

Maybe change to:

// Purpose: returns a pointer to a function, given a module
// Input  : pModuleName - module name
//          *pName - proc name
//static hlds_run wants to use this function
void *Sys_GetProcAddress(const char *pModuleName, const char *pName)
{
    return (void*)GetProcAddress(GetModuleHandle(pModuleName), pName);
}

// Purpose: returns a pointer to a function, given a module
// Input  : pModuleName - module name
//          *pName - proc name
// hlds_run wants to use this function
void *Sys_GetProcAddress(void *pModuleHandle, const char *pName)
{
    return (void*)GetProcAddress((HMODULE)pModuleHandle, pName);
}
In file included from ReAPI.cpp:4:
include/cssdk/public/interface.cpp: In function 'void* Sys_GetProcAddress(const char*, const char*)':
include/cssdk/public/interface.cpp:112:30: error: invalid conversion from 'FARPROC' {aka 'int (__attribute__((stdcall)) *)()'} to 'void*' [-fpermissive]
  112 |         return GetProcAddress(GetModuleHandle(pModuleName), pName);
      |                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              |
      |                              FARPROC {aka int (__attribute__((stdcall)) *)()}
include/cssdk/public/interface.cpp: In function 'void* Sys_GetProcAddress(void*, const char*)':
include/cssdk/public/interface.cpp:121:30: error: invalid conversion from 'FARPROC' {aka 'int (__attribute__((stdcall)) *)()'} to 'void*' [-fpermissive]
  121 |         return GetProcAddress((HMODULE)pModuleHandle, pName);
      |                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              |
      |                              FARPROC {aka int (__attribute__((stdcall)) *)()}
mingw32-make[1]: *** [Makefile:62: Release/ReAPI.o] Error 1

It will solve the problem to use CSSDK on MinGW32