我希望优雅地处理所有内部错误,而无需程序终止.
作为讨论在这里,使用_set_se_translator 捕捉除以零错误.
但是它没有捕获,例如,C运行时库错误-1073740777(0xc0000417),这可能是由printf的格式字符串引起的,它们的百分号不应该出现.(这只是一个例子;当然我们应该检查这样的字符串).要处理这些,需要_set_invalid_parameter_handler.
此外,这个将捕获未捕获的C++异常:SetUnhandledExceptionFilter.因此,它可以与__set__ ...函数一起使用.(关于在MSVC 2008中使用它的文章.)
我想捕获任何和所有错误,以便我可以处理它们(通过记录,抛出现代C++标准异常并返回特定于应用程序的错误代码).是否有一个捕获一切的处理程序?
另请参阅StackOverflow上的内容.
我正在使用Visual Studio 2008.
我在网上做了一些研究,但没有找到-1073741676Code::Blocks 显示的错误代码的解释。
确切的错误消息是Process terminated with status -1073741676 (0 minute(s), 8 second(s))。
对于这个精确的状态是否有一个全局的、恒定的解释,或者它是否会随着编译器、IDE 或任何其他变量的变化而改变?
\n\n代码(尽可能少):
\n\n主程序
\n\n int n(0), choix(0);\n string dis;\n // Nobel* laureats = saisie(n); // Saisie \xc3\xa0 la main\n\n Nobel* laureats = lecture(n);\n cin >> dis;\n cout << agemoyen(laureats, n, dis) << endl;\nRun Code Online (Sandbox Code Playgroud)\n\n诺贝尔.h
\n\n#ifndef NOBEL_H_INCLUDED\n#define NOBEL_H_INCLUDED\n\n#include <string>\n\n\nstruct Nobel\n{\n std::string nom, discipline;\n int annee, age;\n std::string pays;\n};\nint agemoyen(Nobel* NO, int n, std::string dis);\nNobel* lecture(int& n);\n\n#endif // NOBEL_H_INCLUDED\nRun Code Online (Sandbox Code Playgroud)\n\n …