如何知道哪些函数调用另一 [英] How to know what function called another

查看:93
本文介绍了如何知道哪些函数调用另一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有什么办法可以知道当前正在执行的函数被调用,这是在什么文件和行。
我使用的是C语言,而我正在寻找类似的东西来__FUNCTION__,__LINE__ __FILE__或宏。

I wanna know if there is any way to know where the function currently in execution was called, this is, in what file and line. I'm using C language, and I'm looking for something similar to __FUNCTION__, __LINE__ or __FILE__ macros.

推荐答案

重命名功能

void Function(param1)
{
}

void Function_debug(param1, char * file, char * func, unsigned long line)
{
}

然后#定义这样的宏:

Then #define a macro like this:

#define Function(param1) Function_debug(param1, __FILE__, __FUNCTION__, __LINE__)

这篇关于如何知道哪些函数调用另一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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