zoukankan      html  css  js  c++  java
  • Visual Studio调试技巧---Output窗口输出定位

    在使用VC++时,经常使用OutputDebugString往往Output窗口写一些调试信息,如果输出信息遵循某种格式,那么在Output窗口中点击相应输出文本就会跳到相应的代码行中。具体格式MSDN中有说,简单的说法,在输出文本的最前面是"文件名(行号):"的格式就可以了。一个例子,用在我的内存泄露检测代码中:

    wsprintf(output_temp,"%s(%d): >>>>>>>>>>>>mem leaks! size=%d",
                memory_allocated[i].file, 
                memory_allocated[i].line,
                memory_allocated[i].size);
            OutputDebugString(output_temp);

    重点在于 %s(%d): 一定是在最前面,而且冒号是不能少的。当然提供的file和line必须是正确的,使用编译器提高的__FILE__和__LINE__就可以了。

  • 相关阅读:
    @codeforces
    @atcoder
    @loj
    @atcoder
    @atcoder
    @loj
    @atcoder
    @atcoder
    @atcoder
    @uoj
  • 原文地址:https://www.cnblogs.com/yilang/p/12468725.html
Copyright © 2011-2022 走看看