Debugmsg
This macro is used to output debugging information conditionally.
Prototype:
Debugmsg (condition, printf_expr)
Description:
The first parameter is a Boolean value and determines whether the message is output. True: output; false: No output.
The second parameter is similarPrintfFunction. Note:This parameter must be enclosed in brackets.. Parameters will be passedNkdbuplintfFunction.
In wince or WM development, remember that the format control of the second parameter of debugmsg isUnicodeIn the following exampleTextIt is similarPrintfThe form of parameter passing.
The following is an example on msdn:
-
- Debugmsg(True,(Text("Testing item count against maximum % u \ r \ n"),
-
- Dwmaxnumberofitems));
-
- Debugmsg(Dwcurrentnumberofitems> =Dwmaxnumberofitems,
-
- (Text("Invalid item count! Found % u, expected less than % u \ r \ n"),
- Dwcurrentnumberofitems,Dwmaxnumberofitems));
Output:
Testing Item Count Against Maximum68
Invalid Item Count!Found343,Expected Less Than68
Let's take a look at the example below:
- Char Szout[] ="Hello, debugmsg";
- Debugmsg(True,(Text("% S \ n"),Szout));
Output:
§H has been written into mongod \ uc1g
The output is garbled. Why? Because the format is controlled to unicode characters, the input character or string-type condition parameter must also be UNICODE characters, as shown below:
- Tchar Szwout[20] = {0 };
- Multibytetowidechar(Cp_acp, 0,Szout,-1,Szwout, 20 );
- Debugmsg(True,(Text("% S \ n"),Szwout));
Output:
Hello,Debugmsg
Everything is correct.
Good luck!