summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/kwsys/DynamicLoader.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index 486d5b3..a044dff 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -359,10 +359,14 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
DynamicLoader::LibraryHandle lib, const char* sym)
{
- void* result = dlsym(lib, sym);
-
// Hack to cast pointer-to-data to pointer-to-function.
- return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+ result.pvoid = dlsym(lib, sym);
+ return result.psym;
}
//----------------------------------------------------------------------------