63 #ifndef support_diagnostics_h 64 #define support_diagnostics_h 68 #if defined(__cplusplus) 78 #if defined(__cplusplus) 79 #define DIAG_EXTERN extern "C" 81 #define DIAG_EXTERN extern 88 #define DIAG_DBG_LVL 0 104 unsigned int lineno);
134 #define DIAG_If(level) if (level <= DIAG_DBG_LVL_PUB) 137 #define DIAG_DevIf(level) if (level <= DIAG_DBG_LVL) 143 #if defined(__cplusplus) 149 #define DIAG_CERR std::cout 150 #define DIAG_ENDL std::endl 157 #define DIAG_MsgIf_GENERIC(tag, ifexpr, streamArgs) \ 159 DIAG_CERR << tag << streamArgs << DIAG_ENDL; } 162 #define DIAG_MsgIf(ifexpr, streamArgs) \ 163 DIAG_MsgIf_GENERIC("msg: ", ifexpr, streamArgs) 165 #define DIAG_MsgIfCtd(ifexpr, streamArgs) \ 166 DIAG_MsgIf_GENERIC("", ifexpr, streamArgs) 168 #define DIAG_Msg(level, streamArgs) \ 169 DIAG_MsgIf((level <= DIAG_DBG_LVL_PUB), streamArgs) 171 #define DIAG_MsgCtd(level, streamArgs) \ 172 DIAG_MsgIfCtd((level <= DIAG_DBG_LVL_PUB), streamArgs) 175 #define DIAG_DevMsgIf(ifexpr, streamArgs) \ 176 DIAG_MsgIf_GENERIC("msg*: ", ifexpr, streamArgs) 178 #define DIAG_DevMsgIfCtd(ifexpr, streamArgs) \ 179 DIAG_MsgIf_GENERIC("", ifexpr, streamArgs) 181 #define DIAG_DevMsg(level, streamArgs) \ 182 if (level <= DIAG_DBG_LVL) { \ 183 DIAG_CERR << "msg* [" << level << "]: " << streamArgs << DIAG_ENDL; } 186 #define DIAG_WMsgIf(ifexpr, streamArgs) \ 187 DIAG_MsgIf_GENERIC("WARNING: ", ifexpr, streamArgs) 189 #define DIAG_WMsgIfCtd(ifexpr, streamArgs) \ 190 DIAG_MsgIf_GENERIC("", ifexpr, streamArgs) 192 #define DIAG_WMsg(level, streamArgs) \ 193 DIAG_WMsgIf((level <= DIAG_DBG_LVL_PUB), streamArgs) 195 #define DIAG_EMsg(streamArgs) \ 196 DIAG_CERR << "ERROR: " << streamArgs << DIAG_ENDL 198 #define DIAG_DevEMsg(streamArgs) \ 199 { DIAG_CERR << "ERROR: " << streamArgs << DIAG_ENDL; \ 200 if (DIAG_DBG_LVL_PUB) { \ 201 DIAG_CERR << "\t[" << __FILE__ << ":" << __LINE__ << "]" << DIAG_ENDL; } \ 204 #define DIAG_Assert(expr, streamArgs) \ 205 if (!(expr)) DIAG_Throw(streamArgs) 207 #define DIAG_AssertWarn(expr, streamArgs) \ 208 if (!(expr)) DIAG_EMsg(streamArgs) 211 #define DIAG_Die(streamArgs) \ 212 DIAG_Throw(streamArgs) 215 #define DIAG_Throw(streamArgs) \ 216 { std::ostringstream WeIrDnAmE; \ 217 WeIrDnAmE << streamArgs ; \ 218 throw Diagnostics::FatalException(WeIrDnAmE.str(), __FILE__, __LINE__); } 220 #define DIAG_ThrowX(ExceptionClass, streamArgs) \ 221 { std::ostringstream WeIrDnAmE; \ 222 WeIrDnAmE << streamArgs ; \ 223 throw ExceptionClass(WeIrDnAmE.str(), __FILE__, __LINE__); } 232 #if !defined(__cplusplus) 236 #define DIAG_MsgIf(ifexpr, ...) \ 238 fputs("msg: ", stdout); \ 239 fprintf(stdout, __VA_ARGS__); fputs("\n", stdout); } 241 #define DIAG_Msg(level, ...) \ 242 if (level <= DIAG_DBG_LVL_PUB) { \ 243 fprintf(stdout, "msg [%d]: ", level); \ 244 fprintf(stdout, __VA_ARGS__); fputs("\n", stdout); } 246 #define DIAG_DevMsg(level, ...) \ 247 if (level <= DIAG_DBG_LVL) { \ 248 fprintf(stdout, "msg* [%d]: ", level); \ 249 fprintf(stdout, __VA_ARGS__); fputs("\n", stdout); } 251 #define DIAG_EMsg(...) \ 252 { fputs("ERROR: ", stdout); \ 253 fprintf(stdout, __VA_ARGS__); fputs("\n", stdout); \ 256 #define DIAG_DevEMsg(...) \ 257 { fputs("ERROR: ", stdout); \ 258 fprintf(stdout, __VA_ARGS__); fputs("\n", stdout); \ 259 if (DIAG_DBG_LVL_PUB) { \ 260 fprintf(stdout, "\t[%s:%d]\n", __FILE__, __LINE__); } \ 267 #define DIAG_Die(...) \ 268 DIAG_EMsg(__VA_ARGS__); \ 269 { Diagnostics_TheMostVisitedBreakpointInHistory(__FILE__, __LINE__); exit(1); } DIAG_EXTERN void Diagnostics_TheMostVisitedBreakpointInHistory(const char *filenm, unsigned int lineno)
const char * DIAG_Unimplemented
const char * DIAG_UnexpectedInput
DIAG_EXTERN void Diagnostics_SetDiagnosticFilterLevel(int lvl)
DIAG_EXTERN int Diagnostics_GetDiagnosticFilterLevel()
const char * DIAG_UnexpectedOpr