c - How can we know the caller function's name? -
in c language, __function__ can used current function's name. if define function named a() , called in b(), below:
b() { a(); } now, in source code, there lots of functions b() call a(), e.g. c(), d(), e()...
is possible, within a(), add code detect name of function called a()?
further:
- sorry misleading typo. have corrected it.
- i trying find out function calls a() debugging purposes. don't know how when in same situation?
- and code under vxworks, not sure whether related c99 or else.
there's nothing can in a.
however, simple macro trick, can achieve want, iiuc showing name of caller.
void a() { /* code */ } void a_special( char const * caller_name ) { printf( "a called %s", caller_name ); a(); } #define a() a_special( __func__) void b() { a(); }
Comments
Post a Comment