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:

  1. sorry misleading typo. have corrected it.
  2. i trying find out function calls a() debugging purposes. don't know how when in same situation?
  3. 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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -