31
31
* File Description:
32
32
* Setup #NDEBUG and #_DEBUG preprocessor macro in a way that ASSERTs
33
33
* will be active even in the "Release" mode (it's useful for test apps).
34
* Special wrapper for shared CONNECT library use in both C and C++ tkits.
37
38
#include "../ncbi_config.h"
40
#if defined(NCBI_OS_MAC) || \
41
(defined(NCBI_OS_DARWIN) && defined(NCBI_COMPILER_METROWERKS))
45
#elif defined(NCBI_OS_MSWIN)
55
/* Suppress popup messages on execution errors.
56
* NOTE: Windows-specific, suppresses all error message boxes in both runtime
57
* and in debug libraries, as well as all General Protection Fault messages.
58
* Environment variable DIAG_SILENT_ABORT must be set to "Y" or "y".
61
/* Handler for "Unhandled" exceptions */
62
static LONG CALLBACK _SEH_Handler(EXCEPTION_POINTERS* ep)
64
/* Always terminate a program */
65
return EXCEPTION_EXECUTE_HANDLER;
68
static int _SuppressDiagPopupMessages(void)
70
/* Check environment variable for silent abort app at error */
71
const char* value = getenv("DIAG_SILENT_ABORT");
72
if (value && (*value == 'Y' || *value == 'y')) {
73
/* Windows GPF errors */
74
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
75
SEM_NOOPENFILEERRORBOX);
78
_set_error_mode(_OUT_TO_STDERR);
81
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
82
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
83
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
84
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
85
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
86
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
89
SetUnhandledExceptionFilter(_SEH_Handler);
94
/* Put this function at startup init level 'V', far enough not to mess up with
95
* base RTL init, which happens at preceding levels in alphabetical order.
97
# pragma data_seg(".CRT$XIV")
99
static int (*_SDPM)(void) = _SuppressDiagPopupMessages;
103
#endif /*defined(NCBI_OS_...)*/
113
/* IRIX stdlib fix (MIPSpro compiler tested): assert.h already included above*/
120
/* Likewise on OSF/1 (at least with GCC 3, but this never hurts) */
127
/* ...and on Darwin (at least with GCC 3, but this never hurts) */
128
#ifdef NCBI_OS_DARWIN
129
# ifdef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
130
# undef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
139
#define _ASSERT assert
143
* --------------------------------------------------------------------------
144
* $Log: test_assert.h,v $
145
* Revision 6.25 2005/04/07 16:27:30 ivanov
146
* _SuppressDiagPopupMessages(): added handling of "Unhandled" exceptions
148
* Revision 6.24 2005/02/22 19:49:55 ivanov
149
* Added more suppress modes for SetErrorMode()
151
* Revision 6.23 2004/12/21 03:44:42 lavr
152
* Fix CRT report file destination, _CRTDBG_FILE_STDERR not stderr!
154
* Revision 6.22 2004/06/10 19:20:27 ivanov
155
* _SuppressDiagPopupMessages() returns 'int' to avoid runtime errors on MSVC7
157
* Revision 6.21 2003/03/12 21:25:19 lavr
158
* More elaborate conditional branch for Mac's Codewarrior
160
* Revision 6.20 2003/03/12 20:54:45 lavr
161
* Add NCBI_OS_MAC branch and sync include/test and connect/test locations
163
* ===========================================================================
39
#include "test_assert_impl.h"
166
41
#endif /* TEST_ASSERT__H */