platform specific dynamic library loading

This commit is contained in:
2025-10-22 19:20:48 +02:00
parent 8b26742c63
commit 9d8dad7ea1
+32
View File
@@ -0,0 +1,32 @@
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h>
#endif
void *platform_load_library(const char *path)
{
#ifdef _WIN32
return (void *)LoadLibraryA(path);
#else
return dlopen(path, RTLD_NOW);
#endif
}
void platform_unload_library(void *handle)
{
#ifdef _WIN32
FreeLibrary((HMODULE)handle);
#else
dlclose(handle);
#endif
}
void *platform_get_symbol(void *handle, const char *symbol)
{
#ifdef _WIN32
return (void *)GetProcAddress((HMODULE)handle, symbol);
#else
return dlsym(handle, symbol);
#endif
}