LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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