现在的位置: 首页 > 综合 > 正文

print message to debug output window (VS)

2012年08月10日 ⁄ 综合 ⁄ 共 827字 ⁄ 字号 评论关闭
Some times we could want to print the debug messages to a window (console or windows) or a file, we debug our programms with these information. There's a better way to debug programm, print the message to output window if you use VS, and you can double click the message to locate the source codes. To achive this, you only need to:

1. sprintf the message to format as: __FILE__(__LINE__):message string

2. Invoke OutputDebugString() to print the message to ouput window.

Note: for c++, OutputDebugString() is for printing message into Output window; for dotnet, Debug.WriteLine() is for the same purpose.

else, you should want to print some messages to output window when compiling, yes you only need to:

1. format the message string

#define Stringize( L ) #L
#define MakeString( M, L ) M(L)
#define $Line MakeString(Stringize, __LINE__)
#define Reminder(_s_) __FILE__"("$Line"):"_s_

2. output

#pragma message(Reminder("aabbccddeeff"))

转自:http://blog.csdn.net/sunningPig

抱歉!评论已关闭.