如何得到函数mangling后的名字?
在编译过过程中,编译器会将重载和继承函数转换为不同的c函数名,请问如何得到转换后的名字?vc中有__FUNCDNAME__可以实现该功能,请问在g++下有什么办法吗?最好是使用c++标准的东西,尽量不使用编译器扩展的东西,多谢了! 问题点数:100、回复次数:4Top
1 楼jiangsheng(蒋晟.Net[MVP])回复于 2006-03-16 15:37:42 得分 50
__FUNCDNAME__是C99标准,g++应该支持的吧?g++似乎有自己的扩展 __PRETTY_FUNCTION__Top
2 楼houdy(致力于图像/图形领域,成为有思想的程序员)回复于 2006-03-16 18:53:22 得分 20
function name mangling 本身就是编译器行为,C++标准中应该没有明确指出name mangling该怎么实现。所以我觉得,查看name mangling后的接过还是需要编译器支持的。
Top
3 楼fangrk(加把油,伙计!)回复于 2006-03-16 19:34:21 得分 20
好像是编译器的实现细节,干嘛要知道这个?各个编译器的方法可能都有出入,虽然最终可能会统一。Top
4 楼ugg(逸学堂(exuetang.net))回复于 2006-03-16 20:01:52 得分 10
ANSI-Compliant Predefined Macros
Macro Description
__DATE__ The compilation date of the current source file. The date is a string literal of the form Mmm dd yyyy. The month name Mmm is the same as for dates generated by the library function asctime declared in TIME.H.
__FILE__ The name of the current source file. __FILE__ expands to a string surrounded by double quotation marks.
You can create your own wide string version of __FILE__ as follows:
__LINE__ The line number in the current source file. The line number is a decimal integer constant. It can be altered with a #line directive.
__TIME__ The most recent compilation time of the current source file. The time is a string literal of the form hh:mm:ss.
Microsoft-Specific Predefined Macros
__FUNCDNAME__ Valid only within a function and returns the decorated name of the enclosing function (as a string). __FUNCDNAME__ is not expanded if you use the /EP or /P compiler option.
Top




