diff --git a/source/backend/plugin/CarlaPluginInternal.hpp b/source/backend/plugin/CarlaPluginInternal.hpp index 7919680d9..aca5ce327 100644 --- a/source/backend/plugin/CarlaPluginInternal.hpp +++ b/source/backend/plugin/CarlaPluginInternal.hpp @@ -217,8 +217,8 @@ struct CarlaPlugin::ProtectedData { bool enabled; bool needsReset; - void* lib; - void* uiLib; + lib_t lib; + lib_t uiLib; // misc int8_t ctrlChannel; diff --git a/source/bridges-ui/CarlaBridgeClient.hpp b/source/bridges-ui/CarlaBridgeClient.hpp index b9efa2328..3592c3115 100644 --- a/source/bridges-ui/CarlaBridgeClient.hpp +++ b/source/bridges-ui/CarlaBridgeClient.hpp @@ -117,7 +117,7 @@ private: struct UI { CarlaBridgeToolkit* const toolkit; CarlaString filename; - void* lib; + lib_t lib; bool quit; UI(CarlaBridgeToolkit* const toolkit_) diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 1d8f52642..0f5d32687 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -1638,7 +1638,7 @@ int main(int argc, char* argv[]) } bool openLib = false; - void* handle = nullptr; + lib_t handle = nullptr; switch (type) { diff --git a/source/utils/CarlaLibCounter.hpp b/source/utils/CarlaLibCounter.hpp index 574d30330..6c7000207 100644 --- a/source/utils/CarlaLibCounter.hpp +++ b/source/utils/CarlaLibCounter.hpp @@ -58,7 +58,7 @@ public: fLibs.clear(); } - void* open(const char* const filename, const bool canDelete = true) noexcept + lib_t open(const char* const filename, const bool canDelete = true) noexcept { CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr); @@ -87,7 +87,7 @@ public: } } - void* const libPtr(lib_open(filename)); + const lib_t libPtr(lib_open(filename)); if (libPtr == nullptr) { @@ -108,7 +108,7 @@ public: return nullptr; } - bool close(void* const libPtr) noexcept + bool close(const lib_t libPtr) noexcept { CARLA_SAFE_ASSERT_RETURN(libPtr != nullptr, false); @@ -151,7 +151,7 @@ public: private: struct Lib { - void* lib; + lib_t lib; const char* filename; int count; bool canDelete; diff --git a/source/utils/CarlaLibUtils.hpp b/source/utils/CarlaLibUtils.hpp index c77c9f831..9435dfd9e 100644 --- a/source/utils/CarlaLibUtils.hpp +++ b/source/utils/CarlaLibUtils.hpp @@ -20,8 +20,11 @@ #include "CarlaUtils.hpp" -#ifndef CARLA_OS_WIN +#ifdef CARLA_OS_WIN +typedef HMODULE lib_t; +#else # include +typedef void* lib_t; #endif // ----------------------------------------------------------------------- @@ -32,13 +35,13 @@ * May return null, in which case "lib_error" has the error. */ static inline -void* lib_open(const char* const filename) noexcept +lib_t lib_open(const char* const filename) noexcept { CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr); try { #ifdef CARLA_OS_WIN - return (void*)::LoadLibraryA(filename); + return ::LoadLibraryA(filename); #else return ::dlopen(filename, RTLD_NOW|RTLD_LOCAL); #endif @@ -50,13 +53,13 @@ void* lib_open(const char* const filename) noexcept * If false is returned, "lib_error" has the error. */ static inline -bool lib_close(void* const lib) noexcept +bool lib_close(const lib_t lib) noexcept { CARLA_SAFE_ASSERT_RETURN(lib != nullptr, false); try { #ifdef CARLA_OS_WIN - return ::FreeLibrary((HMODULE)lib); + return ::FreeLibrary(lib); #else return (::dlclose(lib) == 0); #endif @@ -69,14 +72,14 @@ bool lib_close(void* const lib) noexcept */ template static inline -Func lib_symbol(void* const lib, const char* const symbol) noexcept +Func lib_symbol(const lib_t lib, const char* const symbol) noexcept { CARLA_SAFE_ASSERT_RETURN(lib != nullptr, nullptr); CARLA_SAFE_ASSERT_RETURN(symbol != nullptr && symbol[0] != '\0', nullptr); try { #ifdef CARLA_OS_WIN - return (Func)::GetProcAddress((HMODULE)lib, symbol); + return (Func)::GetProcAddress(lib, symbol); #else return (Func)(uintptr_t)::dlsym(lib, symbol); #endif