4
/* $Id: test_assert.h,v 6.22 2004/06/10 19:20:27 ivanov Exp $
5
* ===========================================================================
8
* National Center for Biotechnology Information
10
* This software/database is a "United States Government Work" under the
11
* terms of the United States Copyright Act. It was written as part of
12
* the author's official duties as a United States Government employee and
13
* thus cannot be copyrighted. This software/database is freely available
14
* to the public for use. The National Library of Medicine and the U.S.
15
* Government have not placed any restriction on its use or reproduction.
17
* Although all reasonable efforts have been taken to ensure the accuracy
18
* and reliability of the software and data, the NLM and the U.S.
19
* Government do not and cannot warrant the performance or results that
20
* may be obtained by using this software or data. The NLM and the U.S.
21
* Government disclaim all warranties, express or implied, including
22
* warranties of performance, merchantability or fitness for any particular
25
* Please cite the author in any work or product based on this material.
27
* ===========================================================================
29
* Author: Denis Vakatov
32
* Setup #NDEBUG and #_DEBUG preprocessor macro in a way that ASSERTs
33
* will be active even in the "Release" mode (it's useful for test apps).
37
#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".
60
static int _SuppressDiagPopupMessages(void)
62
/* Check environment variable for silent abort app at error */
63
const char* value = getenv("DIAG_SILENT_ABORT");
64
if (value && (*value == 'Y' || *value == 'y')) {
65
/* Windows GPF errors */
66
SetErrorMode(SEM_NOGPFAULTERRORBOX);
69
_set_error_mode(_OUT_TO_STDERR);
72
_CrtSetReportFile(_CRT_WARN, stderr);
73
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
74
_CrtSetReportFile(_CRT_ERROR, stderr);
75
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
76
_CrtSetReportFile(_CRT_ASSERT, stderr);
77
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
82
/* Put this function at startup init level 'V', far enough not to mess up with
83
* base RTL init, which happens at preceding levels in alphabetical order.
85
# pragma data_seg(".CRT$XIV")
87
static int (*_SDPM)(void) = _SuppressDiagPopupMessages;
91
#endif /*defined(NCBI_OS_...)*/
101
/* IRIX stdlib fix (MIPSpro compiler tested): assert.h already included above*/
108
/* Likewise on OSF/1 (at least with GCC 3, but this never hurts) */
115
/* ...and on Darwin (at least with GCC 3, but this never hurts) */
116
#ifdef NCBI_OS_DARWIN
117
# ifdef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
118
# undef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
127
#define _ASSERT assert
131
* --------------------------------------------------------------------------
132
* $Log: test_assert.h,v $
133
* Revision 6.22 2004/06/10 19:20:27 ivanov
134
* _SuppressDiagPopupMessages() returns 'int' to avoid runtime errors on MSVC7
136
* Revision 6.21 2003/03/12 21:25:19 lavr
137
* More elaborate conditional branch for Mac's Codewarrior
139
* Revision 6.20 2003/03/12 20:54:45 lavr
140
* Add NCBI_OS_MAC branch and sync include/test and connect/test locations
142
* ===========================================================================
145
#endif /* TEST_ASSERT__H */