返回   cpper编程论坛 > C/CPP/TMP/GP
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2007-05-10
初级会员
 
注册日期: 2007-03-22
帖子: 15
graphicboy 正向着好的方向发展
默认 发现 VC OUPUT 窗口一个意思的功能

在调试模式下运行自己的程序,用 OutputDebugString 函数可以把调试信息输出到 VC 的 OUTPUT 窗口,这个没有什么,大家都知道。有意思的是,比如,你输出这样的字符串:

代码:
char szMsg[1024]; sprintf( szMsg, "%s(%d)", __FILE__, __LINE__); OutputDebugString(szMsg)
在 VC OUPUT 窗口用鼠标双击这行话,VC 能直接跳转到对应的文件,对应的行。我觉得很有意思,也许大家早就知道了。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2007-05-10
polyrandom 的头像
超级版主
 
注册日期: 2002-09-03
帖子: 3,138
文章: 20
polyrandom 正向着好的方向发展
默认 回复: 发现 VC OUPUT 窗口一个意思的功能

补充一个技巧:很多函数都会设错误值,也就是GetLastError的值。在VC的Watcher窗口里面输入 $ERR,hr,可以看到这个错误值以及相应的文本描述,调试的时候我常用的
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #3 (permalink)  
旧 2007-05-12
高级会员
 
注册日期: 2003-05-26
帖子: 146
wangwh 正向着好的方向发展
发送 MSN 消息给 wangwh
默认 回复: 发现 VC OUPUT 窗口一个意思的功能

引用:
作者: polyrandom 查看帖子
补充一个技巧:很多函数都会设错误值,也就是GetLastError的值。在VC的Watcher窗口里面输入 $ERR,hr,可以看到这个错误值以及相应的文本描述,调试的时候我常用的
Programming Applications for Microsoft 里面提到是◎ERR,hr;测试了下,在VS6里面,$ERR,hr不对,在VS8里居然可以...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #4 (permalink)  
旧 2007-05-14
普通会员
 
注册日期: 2006-04-17
帖子: 59
ltqin 正向着好的方向发展
默认 回复: 发现 VC OUPUT 窗口一个意思的功能

引用:
作者: graphicboy 查看帖子
在调试模式下运行自己的程序,用 OutputDebugString 函数可以把调试信息输出到 VC 的 OUTPUT 窗口,这个没有什么,大家都知道。有意思的是,比如,你输出这样的字符串:

代码:
char szMsg[1024]; sprintf( szMsg, "%s(%d)", __FILE__, __LINE__); OutputDebugString(szMsg)
在 VC OUPUT 窗口用鼠标双击这行话,VC 能直接跳转到对应的文件,对应的行。我觉得很有意思,也许大家早就知道了。
看来"OUTPUT 窗口"的对于查找定位功能是直接对其字符串解析的.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #5 (permalink)  
旧 2007-05-15
Innocentius 的头像
版主
 
注册日期: 2002-09-11
住址: 上海
帖子: 562
文章: 12
Innocentius 正向着好的方向发展
发送 MSN 消息给 Innocentius
默认 回复: 发现 VC OUPUT 窗口一个意思的功能

From MSDN:

Visual C++ Concepts:

Building a C/C++ Program Formatting the Output of a Custom Build Step or Build Event

If the output of a custom build step or build event is formatted correctly, users get the following benefits:
  • Warnings and errors are counted in the Output window.
  • Output appears in the Task List window.
  • Clicking on the output in the Output window displays the appropriate topic.
  • F1 operations are enabled in the Task List window or Output window.
The format of the output should be:
{filename (line# [, column#]) | toolname} : [anytext] {error | warning} code####: Localizable String [ any text ]

Where:
  • {a | b} is a choice of either a or b.
  • [optional] is an optional parameter
For example:
C:\sourcefile.cpp(134) : error C2143: syntax error : missing ';' before '}'
LINK : fatal error LNK1104: cannot open file 'somelib.lib'


Formatting the Output of a Custom Build Step or Build Event
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #6 (permalink)  
旧 2008-01-07
普通会员
 
注册日期: 2006-04-17
帖子: 59
ltqin 正向着好的方向发展
默认 回复: 发现 VC OUPUT 窗口一个意思的功能

遇到一个问题:同事使用VC8,TRACE不能输入信息到output窗口,不知如何解决?

另外想问TRACE的信息能否重定向到一个文件?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #7 (permalink)  
旧 2008-01-07
普通会员
 
注册日期: 2006-04-17
帖子: 59
ltqin 正向着好的方向发展
默认 回复: 发现 VC OUPUT 窗口一个意思的功能

解决了,他将output中的“程序输出”关掉了
PS:
使用以下代码可以将信息输出到文件:
代码:
... _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, hLogFile); ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用


相似的主题
主题 主题作者 版面 回复 最后发表
[转载]发生在我身上的一段真实经历,没看完不要发表意见,谢谢 cpper 灌水/杂烩/BT 1 2006-03-10 08:09 PM
大家帮我参考一下! wanlang 技术杂烩 8 2004-06-04 01:46 PM
转贴“我发现了qq的一个惊人秘密!”暴笑 lisunway 技术杂烩 0 2004-01-02 02:17 AM
[转载]发生在我身上的一段真实经历(1) by 清晨之恋 polyrandom 技术杂烩 2 2002-09-24 11:58 AM
[转载]发生在我身上的一段真实经历,没看完不要发表意见,谢谢 polyrandom 技术杂烩 0 2002-09-24 11:48 AM


所有时间均为格林尼治时间 +9。现在的时间是 06:50 PM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2009,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0