返回代码所在的代码行,以及所在的函数名

jiangf
返回代码所在的代码行,以及所在的函数名

我想问一下,有没有办法 返回代码所在的代码行,以及所在的函数名

scutan
__LINE__
__FUNCTION__  or __func__

cugb_cat
__LINE__
__func__

77h2_eleven
[quote]原帖由 [i]scutan[/i] 于 2008-6-30 10:44 发表 [url=http://bbs.chinaunix.net/redirect.php?goto=findpost&pid=8701021&ptid=1184408][img]http://bbs.chinaunix.net/images/common/back.gif[/img][/url]
__LINE__
__FUNCTION__  or __func__ [/quote]

__FUNCTION__  or __func__在linux下也有么?

gawk
在函数开头加上
#undef  FUNC_NAME
#define FUNC_NAME "xxxxx"

scutan
[quote]原帖由 [i]77h2_eleven[/i] 于 2008-6-30 13:08 发表 [url=http://bbs.chinaunix.net/redirect.php?goto=findpost&pid=8702281&ptid=1184408][img]http://bbs.chinaunix.net/images/common/back.gif[/img][/url]


__FUNCTION__  or __func__在linux下也有么? [/quote]

嗯. 有的.

xi2008wang
还有一个显示所在的文件
__FILE__

net_robber
[quote]原帖由 [i]77h2_eleven[/i] 于 2008-6-30 13:08 发表 [url=http://bbs.chinaunix.net/redirect.php?goto=findpost&pid=8702281&ptid=1184408][img]http://bbs.chinaunix.net/images/common/back.gif[/img][/url]


__FUNCTION__  or __func__在linux下也有么? [/quote]
这个是gcc 的扩展,只要你用的是gcc