S
Saroj
Is there an way for a function to know who called him ?
baumann@pan said:lastest gcc ,vs.net support __FUNCTION__, use it
#include <stdio.h>
int func1(char * str)
{
printf("called by %s\n",str);
return 0;
}
int main(void)
{
func1(__FUNCTION__);
return 0;
}
baumann@pan said:the lastest C standard has __function__ you use as argument
Saroj said:Is there an way for a function to know who called him ?
pete said:It's not in N869.
What section is it in, in the last or latest C standard?
all this means i should also have a access to modify the function who
is calling.
dont think it will work.
Richard said:That's because it's actually spelled __func__.
I think it cannot be done portably. You will need to write
an implementation specific code for that.
You will need to know the C calling convention for that
architecture. For eg. in PowerPC, when a function is called
the return address is put in Link Register (LR).
Is there an way for a function to know who called him ?
Saroj said:Is there an way for a function to know who called him ?
hi there to know who called the function there is THIS pointer (*this)
which points at the object which invoked the function
BUT This is done
only IN C++
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.