如何以编程方式获取成员函数的修饰名? (在MSVC会更好)

问题描述 投票:0回答:2

我想理解它的原因是我要制作一个像这样的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")

//...
c++ visual-c++ dll
2个回答
0
投票

你试过吗

std::typeinfo::raw_name()


-1
投票

通常的方法是在使用 dumpbin(包含在 MSVC 中)等工具构建后检查 DLL 导出。

dumpbin /exports <filename>.dll > exports.txt

然后打开exports.txt并在列出的导出中查找您想要加载的函数。如果您希望使用运行时符号加载,我不知道有任何自动方法可以执行此操作。 (使用 __declspec(dllexport)/__declspec(dllimport) 执行加载时绑定很容易),但这不适用于运行时加载。

© www.soinside.com 2019 - 2024. All rights reserved.