LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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