c++ - 未调用 std::terminate 处理程序
问题描述
我正在尝试示例程序以了解 std::terminate 功能的工作原理 - 但在 VC++ 2019 上,我总是收到未处理的异常错误:
// set_terminate example
#include <iostream> // std::cerr
#include <exception> // std::set_terminate
#include <cstdlib> // std::abort
void myterminate () {
std::cerr << "terminate handler called\n";
abort(); // forces abnormal termination
}
int main (void) {
std::set_terminate (myterminate);
throw 0; // unhandled exception: calls terminate handler
return 0;
}
我总是在 VC++ 中得到以下错误 -
Unhandled exception at 0x761340B2 in Abandon.exe: Microsoft C++ exception: int at memory location 0x0097FAE8
而预期的输出是 -
terminate handler called
Aborted
我在做什么错?
解决方案
推荐阅读
- azure - 在 Azure DevOps 上,用户如何能够访问组织的每个项目?
- pdf - 如何在@react-pdf/render 中注册日文字体
- laravel - Laravel 8 将变量从控制器传递到视图的问题
- c++ - googletest 无法链接到 DUT
- google-smart-home - 向 GOOGLE 报告状态,请求缺少有效的 API 密钥
- sql-server - 2000万行表的生产环境中将表nvarchar(100)更改为nvarchar(150)
- windows - 忍者:构建停止:子命令失败
- mysql - XAMPP - 无法连接到 TOMCAT、Apache 和 MYSQL
- typescript - 如何从打字稿中另一种类型的成员中获取元组类型?
- javascript - 我可以在 PrimeVue 下拉组件中预先选择一个值吗?