Originally posted by Fordy
Personally, if I wanted to see if a destrutor was called
This is not my intention.
Maybe I wasn't clear enough, sorry : I wrote a class (CallStack) which traces the call stack.
I need to know whether ~CallStack is called due to an exception, if so, output the callstack to the log file / stdout:
Code:
CallStack::~CallStack()
{
/*if( uncaught_exception() )
{
Dump();
}*/
if( !myStackList.empty() )
{
myStackList.pop_back();
}
myStackDepth--;
}
I had to comment out those lines, as they are useless (see my thread starter).
Now let me explain the problem.
The CallStack object is instanciated through a macro in each function.
My problem is that I *have* to insert in the source in every catch block the call to dump() (though the DUMP macro ), which is ugly...
Code:
void donuts()
{
TRACE_FN(donuts); // instanciate CallStack object
try
{
const int a = 0;
int i = i/a; // division by zero - exception is thrown
}
catch(...)
{
DUMP; // dumping the CallStack
cout << "Exception caught!" << "\r\n";
cout.flush();
return;
}
}