且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows上禁用调试断言对话框?

更新时间:2023-11-24 21:31:22

查看_CrtSetReportHook http://msdn.microsoft.com/en-us/library/0yysf5e6.aspx



MSDN通告这是应用程序处理CRT运行时故障(如断言)的强大方法。大概你可以定义一个转储你的过程的报告钩子:

如何为我的进程崩溃时创建minidump?


I have a bunch of unit tests that I'm running in batch mode. Occasionally, one will crash with a debug assertion fired from the Visual C++ library. This causes a dialog to pop up, and the unit tests stop running until I click "OK" to close the dialog.

How can I make a C++ program just crash (like on Linux) when it hits an assertion, instead of popping up the annoying dialog?

Note: I do not want to disable assertions; just the dialog.

Check out _CrtSetReportHook():

http://msdn.microsoft.com/en-us/library/0yysf5e6.aspx

MSDN advertises this as a robust way for an application to handle CRT runtime failures like assertions. Presumably you can define a report hook that dumps your process:

How to create minidump for my process when it crashes?