ENH: add dlSymFound() to check for existence of symbol without warnings
This commit is contained in:
parent
b8f643f3da
commit
f2ff53f7b4
@ -1106,4 +1106,24 @@ void* Foam::dlSym(void* handle, const std::string& symbol)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dlSymFound(void* handle, const std::string& symbol)
|
||||
{
|
||||
if (handle && !symbol.empty())
|
||||
{
|
||||
// clear any old errors - see manpage dlopen
|
||||
(void) ::dlerror();
|
||||
|
||||
// get address of symbol
|
||||
(void) ::dlsym(handle, symbol.c_str());
|
||||
|
||||
// symbol can be found if there was no error
|
||||
return !::dlerror();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -190,9 +190,12 @@ void* dlOpen(const fileName& lib);
|
||||
//- Close a dlopened library using handle. Return true if successful
|
||||
bool dlClose(void*);
|
||||
|
||||
//- Lookup a symbol in a dlopened library using handle
|
||||
//- Lookup a symbol in a dlopened library using handle to library
|
||||
void* dlSym(void* handle, const std::string& symbol);
|
||||
|
||||
//- Report if symbol in a dlopened library could be found
|
||||
bool dlSymFound(void* handle, const std::string& symbol);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user