Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
353 views
Welcome To Ask or Share your Answers For Others

1 Answer

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...