转自:http://blog.chinaunix.net/u2/74100/showart_1154283.html
printf() 与 RETAILMSG() 差别
printf("/n broadcast Hello");
#endif;
RETAILMSG(1,(TEXT("Receive a packet/t/n")));
This macro conditionally outputs a printf-style formatted message.
RETAILMSG (
Expression,
Message
)
第一个参数是bool型,判断是否有效,1有效;第二个参数是相关答应消息!
Parameters
-
Expression
- Boolean expression used to determine if the message would be output. Message
- Expression to be printed using printf format style.
Return Values
None.
Remarks
The printf-style message parameter is output if the Boolean input expression evaluates to TRUE. Note that the parameter Message must be enclosed by parentheses to prevent syntax errors being generated by the preprocessor. This macro should be used sparingly, as it increases the size of retail builds.
Example
dwMaxNumberOfItems));
RETAILMSG(dwCurrentNumberOfItems >= dwMaxNumberOfItems,
(TEXT("Invalid item count! Found %u, expected less than %u/r/n"),
dwCurrentNumberOfItems, dwMaxNumberOfItems));
Output:
Invalid item count! Found 343, expected less than 68
本文探讨了printf与RETAILMSG在嵌入式系统中的应用差异。指出在实时性要求高的场景下,RETAILMSG相较于printf更为高效。此外,文章还提供了如何根据不同版本选择合适的调试输出方法。
1万+

被折叠的 条评论
为什么被折叠?



