Archive for the ‘C’ Category

10/1: Who is Calling Whom?

C, LinuxShawnNo Comments

Have you ever wanted to know which function is calling a specific function. This snippet will help in digging up those pesky dependencies at runtime.

#include < stdio.h >
 
// Fn Function
void Fn( char* val )
{
  printf("Ahoy World! %s\n", val);
}
 
// Debug Call Conversion
#define Fn(...) \
  printf( "%s:%d %s()\n",__FILE__, __LINE__, __FUNCTION__); \
  Fn(__VA_ARGS__)
 
//Main
int main( void )
{
  Fn("Arrr!");
  return 0;
}

Read the rest of this entry »