我想理解它的原因是我要做一个像这样的DLL加载器类:
class DymanicLibraryLoader
{
//some code
template <typename FnPtrT>
FnPtrT GetFunction(std::type_info& fn_type, std::string_view pretty_name)
{
//code
}
};
//...
DynamicLibrary dll {...};
typedef void (SomeClass::* FnPtr)(int);
std::type_info& fntype = typeid(FnPtr);
auto fnptr = dll.GetFunction(fntype, "function")
//...
字符串
2条答案
按热度按时间ifmq2ha21#
你试过
std::typeinfo::raw_name()
吗?s71maibg2#
通常的方法是在使用dumpbin(MSVC中包含)等工具构建后检查DLL导出。
字符串
然后打开exports.txt文件,在列出的导出文件中寻找你想要加载的函数。如果你想使用运行时符号加载,我不知道有什么自动化的方法可以做到这一点。(使用__declspec(dllexport)/__declspec(dllimport)很容易执行加载时绑定),但这不适用于运行时加载。