VC中可以自定義編譯輸出消息

轉自【http://blog.csdn.net/qinchong637/article/details/7528411

 

 

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

但是這樣沒有文件和行數信息,不能定位。

使用如下方式可以定位:

  1. // put the following code in header file or at the beginning of the source file.
  2. #define __STR2__(x) #x
  3. #define __STR1__(x) __STR2__(x)
  4. #define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "
  5. // output the user-define information in the source file.
  6. #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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章