Files
FWS-PacManage/include/dynlib.h
T

22 lines
914 B
C

#pragma once
#ifdef _WIN32
#include <windows.h>
typedef HMODULE dynlib_handle;
inline dynlib_handle dynlib_open(const char* path) { return LoadLibraryA(path); }
inline void* dynlib_sym(dynlib_handle h, const char* name) { return (void*)GetProcAddress(h, name); }
inline void dynlib_close(dynlib_handle h) { FreeLibrary(h); }
inline const char* dynlib_error() {
static char buf[256];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buf, sizeof(buf), NULL);
return buf;
}
#else
#include <dlfcn.h>
typedef void* dynlib_handle;
inline dynlib_handle dynlib_open(const char* path) { return dlopen(path, RTLD_NOW); }
inline void* dynlib_sym(dynlib_handle h, const char* name) { return dlsym(h, name); }
inline void dynlib_close(dynlib_handle h) { dlclose(h); }
inline const char* dynlib_error() { return dlerror(); }
#endif