top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can I print function name?

+7 votes
462 views

I have a function pointer that contains the address of function. I do not want any linux function. I want to compile my code with gcc without any option.
gcc -g my_code.c only.

posted Oct 14, 2013 by Vikas Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
int (*funPtr)(int,int);
int testFunction(int a, int b)
{

   printf("function:%s\n",\__func__);
    //Function code
}
int main()
{
        funPtr=testFunction;
        funPtr(0,0);
        return 0;
}

I am not sure ,If you are looking for this.

answer Oct 15, 2013 by Sony Mohanty
Thanks Sony.
But I have function pointer only.
The pointer is same and at run time a function is being bound  based on code flow . There are lots of function in code Which is being bound I do not know.
So I do not know where to add "printf("function:%s\n",\__func__);"
...