TWUDebugPrintf

The TWUDebugPrintf function writes a formatted text string to the debugging log file. This function is only available in the Debug version of the TWU DLLs (TWU32D.dll and TWUNTD.dll).

void TWUDebugPrintf(
    const TCHAR *pszFormat,
    ...
);

Tip: To make inclusion or exclusion based on the _DEBUG macro easier, you can use the TWULOG macro, which is defined as follows:

#ifdef _DEBUG
#define TWULOG(x)    TWUDebugPrintf x
#else
#define TWULOG(x)    ((void)0)
#endif

You must use this macro with a double set of parentheses, like this:

TWULOG((_T("%s: failed with error %u\n"), pszPath, uResult));

The double parentheses are required to allow the use of a variable number of arguments in the macro expansion, because most C/C++ compilers don't support variadic preprocessor macros.

Parameters

pszFormat
[Input] Formatting string; see Formatting specification below for its syntax.
...
Zero or more arguments for the formatting string specified by pszFormat.

Return value

none

Formatting specification

The formatting specification is similar to that used by printf. It consists of a text string that contains literal text interspersed with formatting specifiers. Each formatting specifier starts with a % (percent) sign and must be matched with a corresponding argument to the right of pszFormat (except for the literal percent character inserted by %%). It must use the following syntax:

%[-][#][0][,][width][.precision][size]type

The options must appear in the order shown and have the following meaning. Options within [brackets] are optional.

Option Description
% Signals the start of a format specification. To insert a literal '%' character, use two in sequence: %%
- Left-align the formatted data within its field width
# Add a prefix or padding: # padding for types a, s, w; # prefix for type p; 0x prefix for x and X types.
0 Zero-pad the data to its field width (overrides # for types a, s, w). If neither # nor 0 is specified, the field is padded with spaces if necessary to achive the minimum width.
, Insert thousands separators for types d, i, and u. The thousands separator follows the locale conventions of the current user.
width Decimal number that specifies the minimum formatted field width. Padding uses 0, #, or spaces, depending on the earlier options.
.precision Decimal number that specifies the maximum formatted width (for types d, i, u, x and X) or the maximum number of characters to copy (for types a, s, w).
size Data size modifier for types d, i, u, x and X; may be one of the following:
Size Description
(none) Default integer width, currently 32 bits for both _WIN32 and _WIN64. Use for int, unsigned int, and related types.
h Half-width (16 bits). Use for short, unsigned short, and related types.
l Long (32 bits, same as I32). Use for long, unsigned long, and related types.
q Quad (64 bits, same as I64). Use for __int64, unsigned __int64, and related types.
I 32 bits for _WIN32 builds, 64 bits for _WIN64 builds. Use for LPARAM, LRESULT, UINT_PTR, etc.
I32 Always 32 bits.
I64 Always 64 bits.
type Data type specifier; may be one of the following:
Type Description
a 0-terminated string in ANSI format. Use for char *, CHAR *, and related types.
c Single character; follows _UNICODE. Use for TCHAR data.
d Signed decimal integer. Use for short, int, long, __int64, and related types.
i Same as d.
p Pointer; follows _WIN32/_WIN64 option. Use for void * and other pointer-sized types.
s 0-terminated string; follows _UNICODE. Use for TCHAR * data.
u Unsigned decimal integer. Use for short, int, long, __int64, and related types.
w 0-terminated string in Unicode format. Use for wchar_t *, WCHAR *, and related types.
x Hexadecimal integer using lowercase letters a-f. Use for short, int, long, __int64, and related types.
X Same as x, but uses uppercase letters A-F.
% Inserts a literal '%' character. There should be no corresponding argument for this pseudo-type.

All other type characters cause TWUDebugPrintf to exit immediately.