我可以解开GCC的RTTI名称吗? [英] Can I ungarble GCC's RTTI names?
问题描述
使用gcc,当我使用typeid请求一个对象/变量的类型,我得到一个不同的结果从type_info :: name方法从我期望在Windows上获得。我在Google上搜索了一下,发现RTTI名字是特定于实现的。
Using gcc, when I ask for an object/variable's type using typeid, I get a different result from the type_info::name method from what I'd expect to get on Windows. I Googled around a bit, and found out that RTTI names are implementation-specific.
问题是,我想获得一个类型的名称,因为它将在Windows上返回。是否有一个简单的方法来做到这一点?
Problem is, I want to get a type's name as it would be returned on Windows. Is there an easy way to do this?
推荐答案
如果是你问的,没有编译器开关, gcc的行为类似于msvc关于 type_info :: name()
返回的名称。
If it's what you're asking, there is no compiler switch that would make gcc behave like msvc regarding the name returned by type_info::name()
.
可以依靠gcc的 __ cxa_demangle
函数。
However, in your code you can rely on the gcc specific __cxa_demangle
function.
实际上有解决您的问题的答案。
参考: libstdc ++手册,第40章。Demangling 。
这篇关于我可以解开GCC的RTTI名称吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!