Always keep a beginner's mind, don't forget the beginner's mind|

园龄:粉丝:关注:

2022-03-15 12:55阅读: 657评论: 0推荐: 0

c++命名粉碎及快速还原

name mangling跟函数重载紧密相关。mangling就是将参数、命名空间、返回值、调用方式等信息加入函数名中,目的就是为了给重载的函数不同的签名,因此调用函数的时候才好确认。

但是有个问题,vsgcc使用了不同的命名粉碎规则,我们不可能花大量精力在学习粉碎规则,如何快速还原,其实编译器早就有对应的工具

vs

undname.exe

这个工具在vs安装时附带的,具体位置可以用evething搜一下,或者打开Visual Studio Developer Command Prompt 即可使用

D:\devel-tools\vs>undname ??2@YAPAXI@Z
Microsoft (R) C++ Name Undecorator
Copyright (C) Microsoft Corporation. All rights reserved.

Undecoration of :- "??2@YAPAXI@Z"
is :- "void * __cdecl operator new(unsigned int)"
gcc

c++filt

这个工具是gcc安装时附带的,在gcc.exe同目录

D:\devel-tools\LLVM\bin>c++filt _ZN6PersonC1Ev
Person::Person()

clang 的命令粉碎和vs是一样的

最后推荐一个网站,它可以解码gccvs的粉碎名称

本文作者:乘舟凉

本文链接:https://www.cnblogs.com/czlnb/p/16007943.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   乘舟凉  阅读(657)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起