将函数签名从编译器语言转换为 c++

发布于 2024-10-04 19:32:48 字数 368 浏览 0 评论 0原文

大家好,我需要列出链接器输出中列出的一些函数。我得到的语法如下:

int foo(int num,double dnum, Temp & temp) (in namespace "funcsns")

变成:

.text._ZN7funcsns3fooEidRNS_4TempE

(您可能从“未定义符号”和打印函数名称的其他一些链接错误中知道它)

现在,我可以编写一个脚本以某种方式将其转换变成一些可读的东西,但我想知道是否有一种智能的方法来做到这一点。

请分享您的想法!
谢谢。

Hey guys, I need to make a list of some functions that are listed in the linker output. The syntax i get is as follows:

int foo(int num,double dnum, Temp & temp) (in namespace "funcsns")

Turns into:

.text._ZN7funcsns3fooEidRNS_4TempE

(You might know it from the "undefined symbol" and some other linking errors that print functions names)

Now, i can write a script that somehow turns it into something readable but i wonder if there is a smart way of doing it.

Please share your ideas!

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

橘虞初梦 2024-10-11 19:32:48

在使用 GNU 工具链的系统上,c++filt 程序正是您所寻找的。它是“binutils”包的一部分。不知道其他系统。

“.text”。不是损坏名称的一部分。运行 c++filt _ZN7funcsns3fooEidRNS_4TempE 会产生 funcsns::foo(int, double, funcsns::Temp&)

On a system using the GNU toolchain, the c++filt program does exactly what you're looking for. It's part of the "binutils" package. Dunno about other systems.

The ".text." isn't part of the mangled name. Running c++filt _ZN7funcsns3fooEidRNS_4TempE yields funcsns::foo(int, double, funcsns::Temp&).

烟酉 2024-10-11 19:32:48

这称为装饰或名称修改。以下是有关它如何适用于各种编译器的一些信息

http://www.kegel.com/mangle.html< /a>

This is called decoration or name mangling. Here is some information on how it works for various compilers

http://www.kegel.com/mangle.html

平生欢 2024-10-11 19:32:48

正如其他人指出的,c++filt 是 GNU 工具链的最佳选择。

这也可以通过编程方式完成(甚至可以从 C 程序):参见abi::__cxa_demangle (这实际上是 c++filt 的作用)。

As indicated by other, c++filt is the way to go for the GNU toolchain.

This can also be done programmaticaly (even from a C program) : see abi::__cxa_demangle (which is actually what c++filt does).

安穩 2024-10-11 19:32:48

Visual Studio 提供的 undname 实用程序(至少我当前使用的 VC2005)与 microsoft Visual C++ 的 c++filt 的作用相同

The undname utility provided with visual studio (At least VC2005 that I'm currently using) does the same as c++filt for microsoft visual c++

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文