add dlerror() call wrapper

This commit is contained in:
Axel Kohlmeyer
2021-10-06 08:45:56 -04:00
parent 7801d112b3
commit 10a8a1b325
3 changed files with 29 additions and 0 deletions

View File

@ -507,6 +507,13 @@ void *platform::dlopen(const std::string &fname)
return (void *) LoadLibrary(fname.c_str());
}
// return dynamic linker error string
std::string platform::dlerror()
{
return "";
}
// close a shared object
int platform::dlclose(void *handle)
{
@ -528,6 +535,15 @@ void *platform::dlopen(const std::string &fname)
return ::dlopen(fname.c_str(), RTLD_NOW | RTLD_GLOBAL);
}
// return dynamic linker error string
std::string platform::dlerror()
{
const char *errmesg = ::dlerror();
if (errmesg) return std::string(errmesg);
else return "";
}
// close a shared object
int platform::dlclose(void *handle)
{

View File

@ -133,6 +133,16 @@ namespace platform {
void *dlopen(const std::string &fname);
/*! Obtain error diagnostic info after dynamic linking function calls
*
* Return a human-readable string describing the most recent error that
* occurred when using one of the functions for dynamic loading objects
* the last call to this function. The string is empty, if there was no error.
*
* \return string with error message or empty */
std::string dlerror();
/*! Close a shared object
*
* This releases the object corresponding to the provided handle.