From 236bccff0880681ef6abffb717515e2a7ebf633f Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Sat, 5 Oct 2024 06:14:55 +0800 Subject: [PATCH] Multiplatform Runtime loaded library clean up. --- src/core/Runtime.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/Runtime.cpp b/src/core/Runtime.cpp index aa44c31..cc02f4e 100644 --- a/src/core/Runtime.cpp +++ b/src/core/Runtime.cpp @@ -22,7 +22,13 @@ #include #include -#include +#if defined(__unix__) || defined(__linux__) +# include +#elif defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) +# include +#else +# error "Unsupported architecture for shared objects or dynamic libraries." +#endif bool Runtime::testMode = false; std::unordered_map Runtime::nativeLibraries; @@ -51,7 +57,11 @@ bool Runtime::hasLoadedLibrary(std::string libName) { void Runtime::cleanUp() { for(const auto& [key, value] : Runtime::nativeLibraries) if(value != nullptr) + #if defined(__unix__) || defined(__linux__) dlclose(value); + #elif defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) + FreeLibrary(value); + #endif Runtime::nativeLibraries.clear(); }