From 93ddd4c11dd06374f22ee8026ca348749d28d4d0 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 3 May 2018 21:22:41 +1000 Subject: [PATCH] library: force typing for symbol queries --- library_posix.cpp | 9 --------- library_posix.hpp | 11 ++++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library_posix.cpp b/library_posix.cpp index 7980a1da..c1aef8eb 100644 --- a/library_posix.cpp +++ b/library_posix.cpp @@ -16,7 +16,6 @@ #include "library_posix.hpp" -#include #include @@ -46,11 +45,3 @@ library_posix::~library_posix () if (m_handle) dlclose (m_handle); } - - -/////////////////////////////////////////////////////////////////////////////// -void* -library_posix::symbol (const char *name) -{ - return dlsym (m_handle, name); -} diff --git a/library_posix.hpp b/library_posix.hpp index 1980be01..afc87cdc 100644 --- a/library_posix.hpp +++ b/library_posix.hpp @@ -19,6 +19,8 @@ #include +#include + namespace util { namespace detail { class library_posix { @@ -30,7 +32,14 @@ namespace util { library_posix (const library_posix&) = delete; library_posix& operator= (const library_posix&) = delete; - void* symbol (const char *name); + template + FunctionT + symbol (const char *name) + { + return reinterpret_cast ( + dlsym (m_handle, name) + ); + } private: void *m_handle;