top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How can I print function name?

+7 votes
76 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 Google+ Share Button LinkedIn Share Button Multiple Social 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__);"
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...