我正在使用 visual studio c++ 编译器,& 在我研究异常处理的过程中,我遇到了许多 visual c++ 编译器不支持的功能, 就像控制可以从函数中抛出的异常一样。 我也无法使用 set_terminate() 修改 terminate() 的功能。 visual c++ 修改 terminate() 也是规范吗?...& 如果是,那么谁能解释为什么微软在其编译器中创建这些规范?...:-x
最佳答案
你是什么意思你无法修改终止
你试过这样的东西吗?
// 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 运行。从命令行编译和执行。
关于c++ - 关于设置 set_terminate 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6898767/