Suppress error dialogs on assertion failures in MinGW.

This commit is contained in:
Victor Zverovich 2014-07-10 11:05:26 -07:00
parent c3a6e01f52
commit 4ecfdd50b6

View File

@ -28,11 +28,17 @@
#include <gtest/gtest.h>
#ifdef _WIN32
# include <windows.h>
# include <crtdbg.h>
#endif
int main(int argc, char **argv) {
#ifdef _WIN32
// Don't display any error dialogs. This also suppresses message boxes
// on assertion failures in MinGW where _set_error_mode/CrtSetReportMode
// doesn't help.
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
// Disable message boxes on assertion failures.
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);