Chinaunix首页 | 论坛 | 博客
  • 博客访问: 740
  • 博文数量: 1
  • 博客积分: 25
  • 博客等级: 民兵
  • 技术积分: 15
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-22 21:49
文章分类
文章存档

2012年(1)

我的朋友
最近访客

分类:

2012-11-06 09:23:27

原文地址:在非mfc中用trace 作者:ariesjzj

自制_trace, 在非mfc程序中调用,在ouput窗口中输出.
 
 

//debug.h

#ifndef __DEBUG_H__
#define __DEBUG_H__

#include <tchar.h>


#ifdef _DEBUG

void _trace(TCHAR * szFormat, ...);

#endif

#ifdef _DEBUG

#define TRACE _trace

#endif

#endif

 

//file debug.cpp
#ifdef _DEBUG

#include <stdio.h>
#include <stdarg.h>
#include <windows.h>

#include "debug.h"
void _trace(TCHAR * szFormat, ...)
{
    TCHAR szBuffer [1024] ;
    va_list pArgList ;

    va_start (pArgList, szFormat) ;

    _vsntprintf (szBuffer, sizeof (szBuffer) / sizeof (TCHAR),
                 szFormat, pArgList) ;

    va_end (pArgList) ;

    OutputDebugString(szBuffer);

}
#endif

 

//main.cpp

#include <stdio.h>
#include <windows.h>
#include "debug.h"

int main()
{
    _trace(TEXT ("The screen is %d pixels wide by %d pixels high."),
        3, 4);
    return 0;
}

阅读(99) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:没有了

给主人留下些什么吧!~~