1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

lib/CGameInterface.cpp: add MinGW workaround

MinGW returns all dynamic library functions as FARPROC, which need
to be cast to actual signatures, and this casts emits
-Wcast-function-type.
So, silence it for GetProcAddress.
This commit is contained in:
Konstantin
2023-01-22 21:05:52 +03:00
parent cf56f7ccce
commit f0cb8b63c7
2 changed files with 8 additions and 0 deletions

View File

@@ -49,12 +49,19 @@ std::shared_ptr<rett> createAny(const boost::filesystem::path & libpath, const s
TGetNameFun getName = nullptr;
#ifdef VCMI_WINDOWS
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
HMODULE dll = LoadLibraryW(libpath.c_str());
if (dll)
{
getName = (TGetNameFun)GetProcAddress(dll, "GetAiName");
getAI = (TGetAIFun)GetProcAddress(dll, methodName.c_str());
}
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif
#else // !VCMI_WINDOWS
void *dll = dlopen(libpath.string().c_str(), RTLD_LOCAL | RTLD_LAZY);
if (dll)