-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbg.h
51 lines (42 loc) · 1.19 KB
/
dbg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//---------------------------------------------------------------------------
#ifndef dbgH
#define dbgH
//---------------------------------------------------------------------------
/* Put the following in the main program file:
std::ostream* dbgout=0;
bool XDEBUG=false;
*/
//
// Set up debugging stuff
//
#include <cstdlib>
#include <iostream>
extern std::ostream* dbgout;
extern bool XDEBUG;
#ifdef NDEBUG
#define dbg if(false) (*dbgout)
#define xdbg if (false) (*dbgout)
#define xxdbg if (false) (*dbgout)
#define Assert(x)
#else
#define dbg if(dbgout) (*dbgout)
#define xdbg if (dbgout && XDEBUG) (*dbgout)
#define xxdbg if (false) (*dbgout)
#define Assert(x) \
do { \
if(!(x)) { \
dbg << "Error - Assert " #x " failed"<<std::endl; \
dbg << "on line "<<__LINE__<<" in file "<<__FILE__<<std::endl; \
std::cerr << "Error - Assert " #x " failed"<<std::endl; \
std::cerr << "on line "<<__LINE__<<" in file "<<__FILE__<<std::endl; \
exit(1); \
} \
} while (false)
#endif
inline void myerror(const std::string& s)
{
dbg << "Error: " << s << std::endl;
std::cerr << "Error: " << s << std::endl;
exit(1);
}
#endif