LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
dbg.h
Go to the documentation of this file.
1 #ifndef MeasAlgoShapeletDbg_H
2 #define MeasAlgoShapeletDbg_H
3 
4 #if 0 // for now, turn this off for LSST.
5 
6 /* Put the following in the main program file:
7 
8  std::ostream* dbgout=0;
9  bool XDEBUG=false;
10 
11 */
12 
13 //
14 // Set up debugging stuff
15 //
16 
17 #include <iostream>
18 #include <stdexcept>
19 
20 #if defined(__GNUC__) && defined(OPENMP_LINK)
21 extern __thread std::ostream* dbgout;
22 extern __thread bool XDEBUG;
23 #else
24 extern std::ostream* dbgout;
25 extern bool XDEBUG;
26 #endif
27 
28 #ifdef _OPENMP
29 #pragma omp threadprivate( dbgout , XDEBUG )
30 #endif
31 
32 struct AssertFailureException :
33  public std::runtime_error
34 {
35  AssertFailureException(const char* e) : std::runtime_error(
36  std::string("Error - Assert ") + e + " failed") {}
37 };
38 
39 #ifdef NDEBUG
40 #define dbg if (false) (*dbgout)
41 #define xdbg if (false) (*dbgout)
42 #define xxdbg if (false) (*dbgout)
43 #define Assert(x)
44 #else
45 #define dbg if (dbgout) (*dbgout)
46 #define xdbg if (dbgout && XDEBUG) (*dbgout)
47 #define xxdbg if (false) (*dbgout)
48 #define Assert(x) \
49  do { \
50  if(!(x)) { \
51  dbg << "Error - Assert " #x " failed"<<std::endl; \
52  dbg << "on line "<<__LINE__<<" in file "<<__FILE__<<std::endl; \
53  throw AssertFailureException(#x); \
54  } \
55  } while(false)
56 #endif
57 
58 #else // Define simple replacements so dbg code can remain without problems.
59 
60 #include "assert.h"
61 #include <ostream>
62 
63 const bool XDEBUG = false;
64 std::ostream*const dbgout = 0;
65 #ifdef USE_CERR_FOR_DBG
66 #define dbg if (true) (std::cerr)
67 #define xdbg if (true) (std::cerr)
68 #else
69 #define dbg if (false) (std::cerr)
70 #define xdbg if (false) (std::cerr)
71 #endif
72 #define xxdbg if (false) (std::cerr)
73 #define Assert(x) assert(x)
74 
75 #endif
76 
77 #endif
const bool XDEBUG
Definition: dbg.h:63
std::ostream *const dbgout
Definition: dbg.h:64