dlerror is not available on Windows
This commit is contained in:
parent
6f0321d8f6
commit
c3e9e956b7
|
@ -16,6 +16,21 @@ static void Harness_UnloadObject(void *obj) {
|
|||
static void *Harness_LoadFunction(void *obj, const char *name) {
|
||||
return GetProcAddress(obj, name);
|
||||
}
|
||||
static const char *Harness_LoadError(void) {
|
||||
static char buffer[512];
|
||||
DWORD cchMsg = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
buffer,
|
||||
sizeof(buffer)-1,
|
||||
NULL);
|
||||
if (cchMsg == 0) {
|
||||
strncpy(buffer, "GetProcAddress failed", sizeof(buffer));
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
static void *Harness_LoadObject(const char *name) {
|
||||
|
@ -27,6 +42,9 @@ static void Harness_UnloadObject(void *obj) {
|
|||
static void *Harness_LoadFunction(void *obj, const char *name) {
|
||||
return dlsym(obj, name);
|
||||
}
|
||||
static const char *Harness_LoadError(void) {
|
||||
return dlerror();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -39,7 +57,7 @@ static void *Harness_LoadFunction(void *obj, const char *name) {
|
|||
#define X_LOAD_FUNCTION(name, ret, args) \
|
||||
STR_JOIN(SYMBOL_PREFIX, name) = Harness_LoadFunction(OBJECT_NAME, "SDL_" #name); \
|
||||
if (STR_JOIN(SYMBOL_PREFIX, name) == NULL) { \
|
||||
fprintf(stderr, "Failed to load %s function: %s (%s)\n", SDL_NAME, "SDL_" #name, dlerror()); \
|
||||
fprintf(stderr, "Failed to load %s function: %s (%s)\n", SDL_NAME, "SDL_" #name, Harness_LoadError()); \
|
||||
goto failure; \
|
||||
}
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue