libDebug.h

Go to the documentation of this file.
00001 #undef D0
00002 #undef DX0
00003 #undef ID0
00004 #undef IDX0
00005 #undef UD0
00006 #undef UDX0
00007 #undef UID0
00008 #undef UIDX0
00009 
00010 //==========================================================================
00011 //==========================================================================
00012 // indented debug no newline
00013 #define IDX0(_c,_s...)                                                                                  \
00014     do {                                                                                                                    \
00015         static volatile int _d##__LINE__=0;                                                 \
00016         if (_d##__LINE__ < 10) {                                                                        \
00017             printf("%s:%d: ",__FILE__ ,__LINE__);                                           \
00018             for (int _n=0; _n<_c; _n++){                                                            \
00019                 printf("\t");                                                                                       \
00020             };                                                                                                              \
00021             printf(_s);                                                                                             \
00022         }                                                                                                                       \
00023         else if (IsIntegral(log2((_d##__LINE__)))) {                                \
00024             printf("%s:%d: [%d] ",__FILE__ ,__LINE__, _d##__LINE__);    \
00025             for (int _n=0; _n<_c; _n++){                                                            \
00026                 printf("\t");                                                                                       \
00027             };                                                                                                              \
00028             printf(_s);                                                                                             \
00029         }                                                                                                                       \
00030         _d##__LINE__++;                                                                                         \
00031     } while(0)
00032 
00033 //==========================================================================
00034 //==========================================================================
00035 // indented debug
00036 #define ID0(_c,_s...)                                                                                       \
00037     do {                                                                                                                    \
00038         static volatile int _d##__LINE__=0;                                                 \
00039         int _dt##__LINE__ = _d##__LINE__;                                                       \
00040         if (_dt##__LINE__ < 10) {                                                                       \
00041             printf("%s:%d: ",__FILE__ ,__LINE__);                                           \
00042             for (int _n=0; _n<_c; _n++){                                                            \
00043                 printf("\t");                                                                                       \
00044             };                                                                                                              \
00045             printf(_s);                                                                                             \
00046             printf("\n");                                                                                           \
00047         }                                                                                                                       \
00048         else if (IsIntegral(log2((_dt##__LINE__)))) {                               \
00049             printf("%s:%d: [%d] ",__FILE__ ,__LINE__, _dt##__LINE__);   \
00050             for (int _n=0; _n<_c; _n++){                                                            \
00051                 printf("\t");                                                                                       \
00052             };                                                                                                              \
00053             printf(_s);                                                                                             \
00054             printf("\n");                                                                                           \
00055         }                                                                                                                       \
00056         _d##__LINE__++;                                                                                         \
00057     } while(0)
00058 
00059 //==========================================================================
00060 //==========================================================================
00061 #define DX0(_s...) do {IDX0(0,_s);} while(0)
00062 
00063 //==========================================================================
00064 //==========================================================================
00065 // debug
00066 #define D0(_s...)   do {ID0(0,_s);} while(0)
00067 
00068 //==========================================================================
00069 //==========================================================================
00070 // unconditional indented debug with no newline
00071 #define UIDX0(_c,_s...)                                                 \
00072     do {                                                                                    \
00073         printf("%s:%d: ",__FILE__ ,__LINE__);               \
00074         for (int _n=0; _n<_c; _n++){                                \
00075             printf("\t");                                                           \
00076         };                                                                                  \
00077         printf(_s);                                                                 \
00078     } while(0)
00079 //==========================================================================
00080 //==========================================================================
00081 // unconditional indented debug
00082 #define UID0(_c,_s...) do {UIDX0(_c,_s); printf("\n");} while(0)
00083 
00084 //==========================================================================
00085 //==========================================================================
00086 // unconditional debug with no newline
00087 #define UDX0(_s...) do {UIDX0(0,_s);} while(0)
00088 
00089 //==========================================================================
00090 //==========================================================================
00091 // unconditional debug
00092 #define UD0(_s...) do {UDX(_s); printf("\n"); } while(0)
00093 
00094 //==========================================================================
00095 //==========================================================================
00096 #undef D
00097 #undef DX
00098 #undef ID
00099 #undef IDX
00100 #undef UD
00101 #undef UDX
00102 #undef UID
00103 #undef UIDX
00104 #undef DEBUGONLY
00105 #if DEBUG >= 0
00106 # define DEBUGONLY(x) x
00107 # define D(x...) D0(x)
00108 # define DX(x...) DX0(x)
00109 # define ID(x...) ID0(x)
00110 # define IDX(x...) IDX0(x)
00111 # define UD(x...) UD0(x)
00112 # define UDX(x...) UDX0(x)
00113 # define UID(x...) UID0(x)
00114 # define UIDX(x...) UIDX0(x)
00115 #else
00116 # define DEBUGONLY(x)
00117 # define D(x...) 
00118 # define DX(x...)
00119 # define ID(x...)
00120 # define IDX(x...)
00121 # define UD(x...)
00122 # define UDX(x...)
00123 # define UID(x...)
00124 # define UIDX(x...)
00125 #endif
00126 
00127 //==========================================================================
00128 //==========================================================================
00129 #undef D1
00130 #undef DX1
00131 #undef ID1
00132 #undef IDX1
00133 #undef UD1
00134 #undef UDX1
00135 #undef UID1
00136 #undef UIDX1
00137 #if DEBUG >= 1
00138 # define D1(x...) D0(x)
00139 # define DX1(x...) DX0(x)
00140 # define ID1(x...) ID0(x)
00141 # define IDX1(x...) IDX0(x)
00142 # define UD1(x...) UD0(x)
00143 # define UDX1(x...) UDX0(x)
00144 # define UID1(x...) UID0(x)
00145 # define UIDX1(x...) UIDX0(x)
00146 #else
00147 # define D1(x...) 
00148 # define DX1(x...)
00149 # define ID1(x...)
00150 # define IDX1(x...)
00151 # define UD1(x...)
00152 # define UDX1(x...)
00153 # define UID1(x...)
00154 # define UIDX1(x...)
00155 #endif
00156 
00157 //==========================================================================
00158 //==========================================================================
00159 #undef D2
00160 #undef DX2
00161 #undef ID2
00162 #undef IDX2
00163 #undef UD2
00164 #undef UDX2
00165 #undef UID2
00166 #undef UIDX2
00167 #if DEBUG >= 2
00168 # define D2(x...) D0(x)
00169 # define DX2(x...) DX0(x)
00170 # define ID2(x...) ID0(x)
00171 # define IDX2(x...) IDX0(x)
00172 # define UD2(x...) UD0(x)
00173 # define UDX2(x...) UDX0(x)
00174 # define UID2(x...) UID0(x)
00175 # define UIDX2(x...) UIDX0(x)
00176 #else
00177 # define D2(x...) 
00178 # define DX2(x...)
00179 # define ID2(x...)
00180 # define IDX2(x...)
00181 # define UD2(x...)
00182 # define UDX2(x...)
00183 # define UID2(x...)
00184 # define UIDX2(x...)
00185 #endif
00186 
00187 //==========================================================================
00188 //==========================================================================
00189 #undef D3
00190 #undef DX3
00191 #undef ID3
00192 #undef IDX3
00193 #undef UD3
00194 #undef UDX3
00195 #undef UID3
00196 #undef UIDX3
00197 #if DEBUG >= 3
00198 # define D3(x...) D0(x)
00199 # define DX3(x...) DX0(x)
00200 # define ID3(x...) ID0(x)
00201 # define IDX3(x...) IDX0(x)
00202 # define UD3(x...) UD0(x)
00203 # define UDX3(x...) UDX0(x)
00204 # define UID3(x...) UID0(x)
00205 # define UIDX3(x...) UIDX0(x)
00206 #else
00207 # define D3(x...) 
00208 # define DX3(x...)
00209 # define ID3(x...)
00210 # define IDX3(x...)
00211 # define UD3(x...)
00212 # define UDX3(x...)
00213 # define UID3(x...)
00214 # define UIDX3(x...)
00215 #endif
00216 
00217 //==========================================================================
00218 //==========================================================================
00219 #undef D4
00220 #undef DX4
00221 #undef ID4
00222 #undef IDX4
00223 #undef UD4
00224 #undef UDX4
00225 #undef UID4
00226 #undef UIDX4
00227 #if DEBUG >= 4
00228 # define D4(x...) D0(x)
00229 # define DX4(x...) DX0(x)
00230 # define ID4(x...) ID0(x)
00231 # define IDX4(x...) IDX0(x)
00232 # define UD4(x...) UD0(x)
00233 # define UDX4(x...) UDX0(x)
00234 # define UID4(x...) UID0(x)
00235 # define UIDX4(x...) UIDX0(x)
00236 #else
00237 # define D4(x...) 
00238 # define DX4(x...)
00239 # define ID4(x...)
00240 # define IDX4(x...)
00241 # define UD4(x...)
00242 # define UDX4(x...)
00243 # define UID4(x...)
00244 # define UIDX4(x...)
00245 #endif

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1