我正在使用visual c++编译器&在我研究异常处理的过程中,我遇到了许多c++编译器无法支持的特性,比如控制函数中可能抛出的异常。而且,我无法使用set_terminate()修改terminate()的功能。如果是的话,修改terminate()?...&也是visual c++的规范吗?那么,有人能解释为什么微软在编译器中创建这些规范吗?
发布于 2011-08-01 13:11:13
你不能修改终止是什么意思?
你试过这样的东西吗?
// 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;
}
不要试图逃避VS。从命令行编译和执行。
https://stackoverflow.com/questions/6898767
复制相似问题