rehlds / reapi

AMX Mod X module, using API regamedll & rehlds
GNU General Public License v3.0
159 stars 104 forks source link

Sys_GetProcAddress - Build failed on MinGW32 #328

Open SmileYzn opened 1 month ago

SmileYzn commented 1 month 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