C.2 Debugging Functions and the WINDEBUGINFO Structure

Applications can use the DebugOutput function to display information on either the debugging terminal or the current debugging computer. The function is especially useful for displaying the full details of calls to functions that generate debugging messages.

DebugOutput includes formatting and message-filtering features that are not available with the OutputDebugString function.

Debugging-system options and filters are provided in the WINDEBUGINFO structure. The WINDEBUGINFO structure has the following form:

typedef struct tagWINDEBUGINFO {
    UINT    flags;             /* valid WINDEBUGINFO members      */
    DWORD   dwOptions;         /* debugging options               */
    DWORD   dwFilter;          /* filter  for trace messages      */
    char    achAllocModule[8]; /* module for alloc break          */
    DWORD   dwAllocBreak;      /* allocs to succeed before break  */
    DWORD   dwAllocCount;      /* number of successful allocs     */
} WINDEBUGINFO;

The values in WINDEBUGINFO can be set and retrieved by using the SetWinDebugInfo and GetWinDebugInfo functions.

You can generate your own debugging messages by using the FatalExit function. This function displays a message that has the same form as a debugging message generated by Windows, using the error value supplied as its only parameter. This function is especially useful for debugging DLLs.

In general, you should remove calls to debugging functions when compiling the final version of your application or library.