1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +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

@ -297,6 +297,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-varargs") # emitted in fuzzylite headers, disabled
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pragmas") # emitted only by ancient gcc 5.5 in MXE build, remove after upgrade
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas") # emitted only by ancient gcc 5.5 in MXE build, remove after upgrade
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") # emitted only by ancient gcc 5.5 in MXE build, remove after upgrade
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized") # emitted only by ancient gcc 5.5 in MXE build, remove after upgrade

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)