我想查看这段代码的错位名称。我应该怎么做。
我尝试过使用 G++ 编译器编译代码并将输出视为 ./a.out,但没有打印任何内容。我在 Windows 中阅读过 dumpbin.exe,但我对 Mac 没有任何了解。
名称处理.cpp
// This demonstrate the nameMangling of function to make their signature.
int square(int x){
return x*x;
}
double square(double y){
return y*y;
}
void nothing1(int a, float b, char c, int &d){
}
void nothing2(char a, int b, float &c, double &d){
}
int main(){
return 0; // Indicate successful termination
}
预期的结果是
__Z6squarei
__Z6平方
__Z8nothing1ifcRi
__Z8nothing2ciRfRd
_主要
对我的问题的任何了解都将不胜感激。谢谢你
最佳答案
如果您没有安装 binutils
,请安装该软件包。
这可能是一个很好的起点:Install binutils on Mac OSX
然后 nm a.out
应该向您显示经过修饰的名称,而 nm -C a.out
应该向您显示经过修饰的名称。
关于c++ - 如何在 Mac 终端中查看 C++ 函数的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54556517/