uLib  User mode C/C++ extended API library for Win32 programmers.
Conditional Debugging Macros

Module Description

These macros are active in _DEBUG builds, and voided in Release builds.

Macros

#define _BREAK   __asm Int 3 /* The original, circa 1996? */
 
#define BREAK_IF(cond)   if (cond) _BREAK
 
#define BREAK()
 
#define DBGBREAK(Msg)   OutputDebugString( Msg ); BREAK()
 
#define TRACE(_lvl, ...)   DPrint(_lvl,__VA_ARGS__)
 
#define _TRACE(_va_)   DPrint##_va_
 
#define TRACEX(_lvl, _fmt, ...)   DPrint(_lvl,_F(_fmt" (%s:%u)\n"),__VA_ARGS__,__FILE__,__LINE__)
 
#define TRACE_IF(cond, ...)   if (cond) DPrint( __VA_ARGS__ )
 
#define TRACEX_IF(_cond, _lvl, _fmt, ...)   if (_cond) DPrint(_lvl,_fmt" (%s:%u)\n",__VA_ARGS__,__FILE__,__LINE__)
 
#define ERROR_TRACE(What)   DP_StdFailMsg( What )
 
#define IF_DEBUG(code)   code
 

Macro Definition Documentation

◆ _BREAK

#define _BREAK   __asm Int 3 /* The original, circa 1996? */

Break into the debugger.

Definition at line 198 of file Debug.h.

◆ BREAK_IF

#define BREAK_IF (   cond)    if (cond) _BREAK

Definition at line 202 of file Debug.h.

◆ BREAK

#define BREAK ( )
Value:
if (IsDebuggerPresent()) _BREAK; \
else MessageBox( NULL, \
_T("Debugging Breakpoint:\nNo debugger present.. You may want to attach one now."), \
dbg_Name, MB_OK| MB_ICONSTOP )
CSTR dbg_Name
Definition: Debug.cpp:114
#define _BREAK
Definition: Debug.h:198

BREAK() breaks into the debugger if the program is being debugged.

Otherwise it stops with a message box,
giving you the opportunity to attach a debugger to the process.

Definition at line 208 of file Debug.h.

◆ DBGBREAK

#define DBGBREAK (   Msg)    OutputDebugString( Msg ); BREAK()

Definition at line 214 of file Debug.h.

◆ TRACE

#define TRACE (   _lvl,
  ... 
)    DPrint(_lvl,__VA_ARGS__)

Typical debug trace.

Definition at line 216 of file Debug.h.

◆ _TRACE

#define _TRACE (   _va_)    DPrint##_va_

Old school (pre __VA_ARGS__): Used w dbl parentheses.

Definition at line 217 of file Debug.h.

◆ TRACEX

#define TRACEX (   _lvl,
  _fmt,
  ... 
)    DPrint(_lvl,_F(_fmt" (%s:%u)\n"),__VA_ARGS__,__FILE__,__LINE__)

Output format: "dbg_Name LEVEL: Fmt and inserts (Filename:Line)\n".. Note: Don't end _fmt with LF, it's added after the line nr.
Also, don't use the _F macro in your _fmt spec, as it's already included.

Definition at line 224 of file Debug.h.

◆ TRACE_IF

#define TRACE_IF (   cond,
  ... 
)    if (cond) DPrint( __VA_ARGS__ )

Trace only if cond evaluates to true..

Definition at line 227 of file Debug.h.

◆ TRACEX_IF

#define TRACEX_IF (   _cond,
  _lvl,
  _fmt,
  ... 
)    if (_cond) DPrint(_lvl,_fmt" (%s:%u)\n",__VA_ARGS__,__FILE__,__LINE__)

See TRACEX for details.

Definition at line 229 of file Debug.h.

◆ ERROR_TRACE

#define ERROR_TRACE (   What)    DP_StdFailMsg( What )

Output form "WhatOperation failed: System error message\n"..

Definition at line 233 of file Debug.h.

◆ IF_DEBUG

#define IF_DEBUG (   code)    code

Include code only in _DEBUG builds.

Definition at line 236 of file Debug.h.