- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,I am looking for a easily way to get, inside a C routine, the name of the caller of that routine. Something like that:
void X () {return MYROUTINE();}void MYROUTINE() {printf ("%s", get_caller_name());}
"get_caller_name()" is exactly what I am looking for. Is there any internal Intel routine able to do that without change so much the code? I have an alternative idea (playing with #define / #undef) but it requires to change a lot of code...
Any help and suggestion is appreciate!
Regards,
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a look at:
http://stackoverflow.com/questions/353180/how-to-i-find-the-calling-function-name
or
http://bytes.com/topic/c/answers/870541-how-know-know-calling-function-name-c-programme
Basically you either have to look through the stack trace, or you have to compile it into the code with the __FUNCTION__ macro.
If you already knew this and there is indeed some "special" feature in the Intel compiler that can achieve this, I would like to know as well.
I hope this is useful to you.
Andreas
http://stackoverflow.com/questions/353180/how-to-i-find-the-calling-function-name
or
http://bytes.com/topic/c/answers/870541-how-know-know-calling-function-name-c-programme
Basically you either have to look through the stack trace, or you have to compile it into the code with the __FUNCTION__ macro.
If you already knew this and there is indeed some "special" feature in the Intel compiler that can achieve this, I would like to know as well.
I hope this is useful to you.
Andreas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
-pg inserts a gprof function call which captures that information, as well as timing your function. You could copy and modify that code (presumably subjecting your application to GPL). Just a variation on the preceding advice.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page