When a program is compiled in debug mode and calls abort() or crashes in another way, an error dialog box pops up that asks whether the debugger should be started. How can I prevent this dialog box from appearing?
It needs to be done via commands that run in this program, or possibly from the program that starts it -- changing the registry is therefore not an option. Only the behavior of this specific program should be changed.
(There were already answers to similar questions, but to my knowledge none that answered this special use case.)
What you're seeing is not Windows Error Reporting. Windows Error Reporting is a feature that uploads crash dumps (usually minidumps) to a server so that developers can diagnose bugs that are happening on a deployed product.
The Abort/Retry/Continue dialog box is a feature of the debug version of the C and C++ run-time libraries. They will show that dialog when
abortis called. That's the default behavior. It turns out you can control some of this with _set_abort_behavior.Assertion failures, which are enabled by default in debug builds, show a similar dialog. If you build and link with release versions of the run-time libraries, these dialogs won't appear (as Hans Passant said in the comments).
Other crashes, like dereferencing a null pointer, are signaled by raising an exception. Even if you aren't using C++-style exceptions, there are system-level exceptions--often called asynchronous exceptions. These are triggered by access violations,
DebugBreak, and other events. C++ exceptions are sometimes called synchronous exceptions. On Windows, they are usually implemented using asynchronous exceptions.If you have a debugger attached (which is the usual case if you launch the program from Visual Studio), first chance and unhandled exceptions will be detected by the debugger. In most cases, the default settings will cause the debugger to suspend program execution, giving the developer a chance to investigate. If you don't want this behavior, you can modify the debugger settings or simply run your program without attaching a debugger.