您的位置:首页 > 其它

VC中可以自定义编译输出消息

2012-10-30 17:55 120 查看
转自【/article/1415716.html





#pragma message("Insert User-defined Information here!")

但是这样没有文件和行数信息,不能定位。

使用如下方式可以定位:

[cpp]
view plaincopyprint?

// put the following code in header file or at the beginning of the source file.

#define __STR2__(x) #x
#define __STR1__(x) __STR2__(x)

#define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "

// output the user-define information in the source file.

#pragma message(__LOC__"User-defined Information")

// put the following code in header file or at the beginning of the source file.
#define __STR2__(x) #x
#define __STR1__(x) __STR2__(x)
#define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "

// output the user-define information in the source file.
#pragma message(__LOC__"User-defined Information")


参考:http://support.microsoft.com/kb/155196/en-us
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: