关于设置set_terminate函数 我使用VisualStudioC++编译器,在研究异常处理时,我遇到了一些VisualC++编译器无法支持的特性, 就像控制可以从函数中抛出的异常一样。 此外,我无法使用set\u terminate()修改terminate()的功能。 VisualC++是否修改了终端()>强>?……如果是,那么有人解释为什么微软在编译器中创建这些规范吗?…--X/P>< P>你不能修改终止< /P>是什么意思?
你试过这样的东西吗关于设置set_terminate函数 我使用VisualStudioC++编译器,在研究异常处理时,我遇到了一些VisualC++编译器无法支持的特性, 就像控制可以从函数中抛出的异常一样。 此外,我无法使用set\u terminate()修改terminate()的功能。 VisualC++是否修改了终端()>强>?……如果是,那么有人解释为什么微软在编译器中创建这些规范吗?…--X/P>< P>你不能修改终止< /P>是什么意思?,c++,visual-c++,exception-handling,C++,Visual C++,Exception Handling,你试过这样的东西吗 // set_terminate example #include <iostream> #include <exception> #include <cstdlib> using namespace std; void myterminate () { cerr << "terminate handler called\n"; abort(); // forces abnormal termination } i
// set_terminate example
#include <iostream>
#include <exception>
#include <cstdlib>
using namespace std;
void myterminate () {
cerr << "terminate handler called\n";
abort(); // forces abnormal termination
}
int main (void) {
set_terminate (myterminate);
throw 0; // unhandled exception: calls terminate handler
return 0;
}
//设置\u终止示例
#包括
#包括
#包括
使用名称空间std;
void myterminate(){
cerr问题是什么?你不明白为什么存在或什么?@sharptooth:我正试图使用set_terminate()设置terminate(),但它没有这样做……我在问原因……好吧,你到底做了什么,什么不起作用?@sharptooth:阅读下面c程序员给出的答案,我也做了同样的事情,但set_terminate无法修改terminate()的工作方式,您能更清楚地解释下面cprogrammer给出的答案吗..原因是Visual Studio在调试环境中运行您的程序。这是必要的,因为您需要断点、查看数据值、访问冲突等功能。它将在IDE中工作,而不是在调试模式下。(即选择调试菜单->无调试启动。或按Ctrl+F5)我使用VS2008,但它在发布模式下也不适用于我。是否有其他可能的原因(如在调试->异常中设置)??至少它在VS2008之外工作。。。