I cannot believe that I didn’t know of this macro all this while. Countless times in the past, when I had to track the life-cycle of an object, I had put code such as printf("inside ctor") and printf("inside function F(int)") in my class, and now I find out that all I had to use was the __FUNCSIG__ macro.
ref class R
{
public:
R()
{
Console::WriteLine(__FUNCSIG__);
}
void Hello()
{
Console::WriteLine(__FUNCSIG__);
}
~R()
{
Console::WriteLine(__FUNCSIG__);
}
int index;
};
//...
R^ r = gcnew R();
r->Hello();
delete r;
/*** Output
__clrcall R::R(void)
void __clrcall R::Hello(void)
__clrcall R::~R(void)
***/
Other similar macros are __FUNCDNAME__ which returns the decorated name and __FUNCTION__ which returns the undecorated name (without the full signature). These are available in VC++ 2003 and 2005, but I am not sure if they existed in VC++ 6, so perhaps someone could confirm that.
Those aren’t available in VC 6. π¦
I guess it’s time to upgrade, Mike π
Cool, I didn’t know this earlier, thanks nish for sharing this piece π