问题描述
您好,
我已经实现了一个小型库,其功能是一种数据类型,以便管理临时存储,以及
管理临时存储,以及处理正确的铸造存储。获得双指针的
函数例如:
double * work_get_double(work_type * work,size_t size){}
现在,如果工作区域不够大,则函数失败,
调用abort。在失败的情况下,我会*非常*
想知道调用work_get_double()的函数的名称,所以如果
函数foo()调用work_get_double( ),并且请求不能满足,我希望work_get_double()失败,例如:
fprintf(stderr,对不起来电来自功能:%s无法满足。中止\ n,CALLER_NAME
abort();
CALLER_NAME,在这种情况下将解析为富。有什么东西
这样可能(没有实际传递函数名称)?
最好的问候
Joakim Hove
-
Joakim Hove
hove AT ntnu.no /
Tlf:+47(55 5)8 27 13 / Stabburveien 18
传真:+47(55 5)8 94 40 / N-5231 Paradis
/ 55 91 28 18/92 68 57 04
Hello,
I have implemented a small library with a function a datatype to
manage temporary storage, and handle out correctly casted storage. The
function to get a double pointer is for instance:
double * work_get_double(work_type *work, size_t size) {}
Now, if the work area is not sufficiently large, the function fails,
with a call to abort. In the case of failure, I would *very much*
like to know the name of the function calling work_get_double(), so if
function foo() calls work_get_double(), and the request can not be
satisfied, I would like work_get_double() to fail with something like:
fprintf(stderr,"Sorry call from function: %s could not satsified. Aborting\n",CALLER_NAME)
abort();
Where CALLER_NAME, in this case would resolve to ''foo''. Is something
like this possible (without actually passing in the function name manually)?
Best Regards
Joakim Hove
--
Joakim Hove
hove AT ntnu.no /
Tlf: +47 (55 5)8 27 13 / Stabburveien 18
Fax: +47 (55 5)8 94 40 / N-5231 Paradis
http://www.ift.uib.no/~hove/ / 55 91 28 18 / 92 68 57 04
推荐答案
好的 - 这至少比完全手动输入
函数名称。在linux / gcc-3.2.3上,变量__FUNCTION__定义为
。
感谢您的帮助。
Joakim: - )
-
Joakim Hove
hove AT ntnu.no /
Tlf:+47(55 5 )8 27 13 / Stabburveien 18
传真:+47(55 5)8 94 40 / N-5231 Paradis
/ 55 91 28 18/92 68 57 04
OK - that is it at least better than fully mannually typing in the
function names. On linux/gcc-3.2.3 the variable __FUNCTION__ is
defined.
Thanks for your help.
Joakim :-)
--
Joakim Hove
hove AT ntnu.no /
Tlf: +47 (55 5)8 27 13 / Stabburveien 18
Fax: +47 (55 5)8 94 40 / N-5231 Paradis
http://www.ift.uib.no/~hove/ / 55 91 28 18 / 92 68 57 04
好的 - 我很害怕。
OK - I was afraid of that.
确定 - 这至少比完全手动输入
函数名更好。在linux / gcc-3.2.3上定义了变量__FUNCTION__。
OK - that is it at least better than fully mannually typing in the
function names. On linux/gcc-3.2.3 the variable __FUNCTION__ is
defined.
在C99中,__ func__是标准的。
In C99, __func__ is standard.
这篇关于确定呼叫功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!