IS NULL终止()处理程序允许?
-
19-09-2019 - |
题
在VC ++ 7,如果我执行以下操作:
void myTerminate()
{
cout << "In myTerminate()";
abort();
}
int main( int, char** )
{
set_terminate( &myTerminate );
set_terminate( 0 );
terminate();
return 0;
}
程序的行为就好像abort()
被直接调用其是默认terminate()
处理程序不正是。
如果我省略set_terminate( 0 );
声明我的终止处理程序被调用。因此调用set_terminate( 0 )
似乎有terminate()
处理程序重置为默认的效果。
这种行为是特定于VC ++只有7?不会在程序运行到未定义的行为,如果我叫set_terminate( 0 )
一些其他实施?
解决方案
寻找到标准揭示了以下内容:
terminate_handler set_terminate(terminate_handler f) throw();
1 效果:建立所述函数 用f作为当前处理程序指定 功能...切点击 的 2 要求:˚F不应是一个空指针强>结果 3 返回:先前terminate_handler
似乎是非标准。
不隶属于 StackOverflow