打印调用函数的函数名称? [英] Print function name of calling function?

查看:370
本文介绍了打印调用函数的函数名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




是否可以打印调用函数的函数名?


例如,f1()和f2 ()两个调用f3(),在f3()中我想

打印调用f3()函数的名称,可以是f1()

或者f2()。


BRs!

Hi,

Is it possible to print the function name of the calling function?

For example, f1() and f2() both calls f3(), in f3() I would like to
print the name of the function calling f3() which could either be f1()
or f2().

BRs!

推荐答案

文章< 11 ** ********************@l53g2000cwa.googlegroups .com> ;,

dspfun< ds **** @ hotmail.comwrote:
In article <11**********************@l53g2000cwa.googlegroups .com>,
dspfun <ds****@hotmail.comwrote:

>是否可以打印调用函数的函数名?
>Is it possible to print the function name of the calling function?



标准C中没有设施。

There is no facility for that in standard C.


>例如,f1()和f2()都调用f3(),在f3()中我想打印调用f3()函数的名称,该函数可以是f1()
或f2( )。
>For example, f1() and f2() both calls f3(), in f3() I would like to
print the name of the function calling f3() which could either be f1()
or f2().



有些系统提供了扩展,允许调用堆栈来检查
,但是C不需要它,它不是'即使在可以完成的系统上也很容易



-

编程就是在你忙着做的时候会发生什么其他计划。

Some systems provide extensions to allow the calling stack to
be examined, but C doesn''t require it, and it isn''t necessarily
easy even on systems where it can be done.
--
Programming is what happens while you''re busy making other plans.


dspfun写道:
dspfun wrote:




是否可以打印调用函数的函数名称?
Hi,

Is it possible to print the function name of the calling function?



不可移植。

Not portably.


例如,f1()和f2()都调用f3() ,在f3()中我想打印
打印调用f3()函数的名称,该函数可以是f1()

或f2()。
For example, f1() and f2() both calls f3(), in f3() I would like to
print the name of the function calling f3() which could either be f1()
or f2().



因此来电者不能依赖f3()表现一致吗?


如果您需要的信息比您多传递函数参数,

明显的建议是简单地添加一些函数参数。

So the caller can''t rely on f3() behaving consistently?

If you need more info than you pass in the function arguments, the
obvious suggestion is to simply add some more function arguments.


08年2月20日:32,Harald van D?3k < true ... @ gmail.comwrote:
On 20 Feb, 08:32, "Harald van D?3k" <true...@gmail.comwrote:

dspfun写道:
dspfun wrote:


Hi,


是否可以打印调用函数的函数名?
Is it possible to print the function name of the calling function?



不可移植。


Not portably.


例如,f1()和f2()都调用f3() ,在f3()中我想打印
打印调用f3()函数的名称,该函数可以是f1()

或f2()。
For example, f1() and f2() both calls f3(), in f3() I would like to
print the name of the function calling f3() which could either be f1()
or f2().



所以来电者不能依赖f3()表现一致吗?


如果你需要的信息多于你传递函数参数,

明显的建议是简单地添加一些函数参数。


So the caller can''t rely on f3() behaving consistently?

If you need more info than you pass in the function arguments, the
obvious suggestion is to simply add some more function arguments.



在gdb中可以获得一个通话跟踪,gdb如何接到电话

trace? gdb是否使用了一些特定于操作系统的功能?

In gdb it is possible to get a call trace, how can gdb get the call
trace? Does gdb use some OS-specific functions for this?


这篇关于打印调用函数的函数名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆