diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index e4a6136..fb280c3 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -38,6 +38,25 @@ "limitSymbolsToIncludedHeaders": true } }, + { + "name": "Win32 (MinGW-w64 cross)", + "compilerPath": "i686-w64-mingw32-gcc", + "includePath": [ + "${workspaceFolder}", + "${workspaceFolder}/libcppunitx" + ], + "defines": [ + "HAVE_CONFIG_H" + ], + "cStandard": "c11", + "cppStandard": "c++11", + "browse": { + "path": [ + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true + } + }, { "name": "Win32 (MSVC)", "intelliSenseMode": "msvc-x64", diff --git a/libcppunitx/module_loader.cpp b/libcppunitx/module_loader.cpp index 3f2902b..996dfb1 100644 --- a/libcppunitx/module_loader.cpp +++ b/libcppunitx/module_loader.cpp @@ -20,6 +20,11 @@ #include #endif +#if _WIN32 +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + #include "module_loader.h" #if HAVE_DLFCN_H @@ -108,24 +113,31 @@ void module::open(const char *const name) close(); #if HAVE_DLFCN_H _native_handle = dlopen(name, RTLD_LAZY); +#elif _WIN32 + _native_handle = LoadLibraryA(name); #endif } void module::close() { -#if HAVE_DLFCN_H native_handle_type handle = nullptr; std::swap(_native_handle, handle); if (handle != nullptr) { +#if HAVE_DLFCN_H dlclose(handle); - } +#elif _WIN32 + FreeLibrary(static_cast(handle)); #endif + } } void *module::sym(const char *symbol) { #if HAVE_DLFCN_H return dlsym(_native_handle, symbol); +#elif _WIN32 + return reinterpret_cast( + GetProcAddress(static_cast(_native_handle), symbol)); #else return nullptr; #endif