开发者

Automatically kill a program when "Debug Assertion Failed" comes up?

开发者 https://www.devze.com 2023-03-25 02:28 出处:网络
I have a Visual C++ program that I use simply for audio recording and sometimes it totally out of the blue crashes and a dialog box comes up, \"Visual C++ Debugging Library\" \"Debug Assertion Failed\

I have a Visual C++ program that I use simply for audio recording and sometimes it totally out of the blue crashes and a dialog box comes up, "Visual C++ Debugging Library" "Debug Assertion Failed" "Abort","Retry","Ignore".

I have no need at all to do Retry or Ignore, so I just want Abort to be run automatically.

I have a batch/bash file that runs to detect that the program ended and to restart it, but when this dialog 开发者_开发技巧comes up, the program still runs and the program just remains crashed until I notice it.


The runtime function _set_error_mode() can arrange this for you. You just need to do this:

_set_error_mode(_OUT_TO_STDERR);

All errors (including those provoked by assertion failures) will print their messages to stderr rather than an interactive message box. This means that your application won't block waiting for input and will proceed to terminate itself immediately.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号