print message to debug output window (VS)

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

posted @ 2011-04-21 17:27  能巴  阅读(462)  评论(0编辑  收藏  举报