Is it possible to get the caller's name in C ?

Way79 2004-08-20 06:52:53
thanks for any help
...全文
83 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
softcar 2004-08-20
  • 打赏
  • 举报
回复
比较难。
sah 2004-08-20
  • 打赏
  • 举报
回复
好像挺难。如果可以,那不就乱套了?因为违反了“调用”的概念啊。可能得设一个个参数,或者全局变量来标志吧?这是我的想法,供你参考。
铖邑 2004-08-20
  • 打赏
  • 举报
回复
what?
pacman2000 2004-08-20
  • 打赏
  • 举报
回复
no name!
tianxiangyuan 2004-08-20
  • 打赏
  • 举报
回复
no
blh 2004-08-20
  • 打赏
  • 举报
回复
If you use the compiler that accords with the c99 stardard, you shall implement it by the following means:

//called function:

int test_func_trace(const char* caller_name, int n);

#define test_func(n) test_func_trace(__func__, (n))

//caller function:

int test()
{
return test_func(100);
}



沙沙的吹 2004-08-20
  • 打赏
  • 举报
回复
C不提供这个机制吧。不过也许有编译器提供这个功能也说不定,也许你在调用调用的时候,将名字用参数传递进去是可以的。

23,116

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧