mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add dlSymFound() to check for existence of symbol without warnings
This commit is contained in:
@ -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
|
//- Close a dlopened library using handle. Return true if successful
|
||||||
bool dlClose(void*);
|
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);
|
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);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user