Skip to content
Snippets Groups Projects
Commit 252af6c3 authored by Albert Gräf's avatar Albert Gräf
Browse files

Improved handling of dlopen/LoadLibrary errors.

These are now proper errors instead of warnings, and the error message
on Windows is more informative as well, making it easier to detect and
diagnose such errors.

Backport from upstream:

https://github.com/pure-data/pure-data/commit/fee700b3
https://github.com/pure-data/pure-data/commit/af3894da
parent eea63d24
No related branches found
No related tags found
1 merge request!839Gem on the Mac
...@@ -250,7 +250,14 @@ gotone: ...@@ -250,7 +250,14 @@ gotone:
ntdll = LoadLibrary(filename); ntdll = LoadLibrary(filename);
if (!ntdll) if (!ntdll)
{ {
verbose(1, "%s: couldn't load", filename); wchar_t wbuf[MAXPDSTRING];
char buf[MAXPDSTRING];
DWORD count, err = GetLastError();
count = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
0, err, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), wbuf, MAXPDSTRING, NULL);
if (!count || !WideCharToMultiByte(CP_UTF8, 0, wbuf, count+1, buf, MAXPDSTRING, 0, 0))
*buf = '\0';
error("%s: %s (%d)", filename, buf, err);
class_set_extern_dir(&s_); class_set_extern_dir(&s_);
return (0); return (0);
} }
...@@ -263,7 +270,7 @@ gotone: ...@@ -263,7 +270,7 @@ gotone:
dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
if (!dlobj) if (!dlobj)
{ {
verbose(1, "%s: %s", filename, dlerror()); error("%s: %s", filename, dlerror());
class_set_extern_dir(&s_); class_set_extern_dir(&s_);
return (0); return (0);
} }
...@@ -277,7 +284,7 @@ gotone: ...@@ -277,7 +284,7 @@ gotone:
if (!makeout) if (!makeout)
{ {
verbose(1, "load_object: Symbol \"%s\" not found", symname); error("load_object: Symbol \"%s\" not found", symname);
class_set_extern_dir(&s_); class_set_extern_dir(&s_);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment