S
siddhu
Dear experts,
Is it a standard behavior that set_terminate handler function gets
called if an exception is thrown and not caught anywhere in the
program?
I know its a C++ forum and I'm facing a problem which is related to
MSDEV but I hope I'll get a solution here for my problem.
I installed a handler in set_terminate() to keep track of crashes and
normal termination. If the handler function is the part of exe it gets
called.
If handler function is in some loaded dll then it does not get
called.
e.g. Code given below works ( i.e. set_terminate handler function gets
called when program has an uncuaght exception), But if handlers are
from a loaded dll then atexit() handler gets called.
And I can not make handlers as part of exe. I have to keep them in a
separate dll.
Any suggestion would be of great help.
#include<iostream>
void term_func()
{
std::cout<<"in term_func"<<std::endl;
abort();
}
void exit_func()
{
std::cout<<"in exit_func"<<std::endl;
}
void func()
{
throw 1;
}
int main(int argc, char *argv[])
{
set_terminate(term_func);
atexit(exit_func);
func();
return 0;
}
Thanks
Siddharth
Is it a standard behavior that set_terminate handler function gets
called if an exception is thrown and not caught anywhere in the
program?
I know its a C++ forum and I'm facing a problem which is related to
MSDEV but I hope I'll get a solution here for my problem.
I installed a handler in set_terminate() to keep track of crashes and
normal termination. If the handler function is the part of exe it gets
called.
If handler function is in some loaded dll then it does not get
called.
e.g. Code given below works ( i.e. set_terminate handler function gets
called when program has an uncuaght exception), But if handlers are
from a loaded dll then atexit() handler gets called.
And I can not make handlers as part of exe. I have to keep them in a
separate dll.
Any suggestion would be of great help.
#include<iostream>
void term_func()
{
std::cout<<"in term_func"<<std::endl;
abort();
}
void exit_func()
{
std::cout<<"in exit_func"<<std::endl;
}
void func()
{
throw 1;
}
int main(int argc, char *argv[])
{
set_terminate(term_func);
atexit(exit_func);
func();
return 0;
}
Thanks
Siddharth