vs2022 Release下支持调试信息的打印,Debug_Trace的实现
主要用到OutputDebugString函数,直接看代码。
Debug_Trace.h
#if !defined(DEBUG_TRACE_INCLUDE_)
#defineDEBUG_TRACE_INCLUDE_
#include <stdio.h>
#include <wTypes.h>
#include <tchar.h>
void Debug_TraceA(char* fmt, ...);
void Debug_TraceW(WCHAR* fmt, ...);
#endif
Debug_Trace.cpp
#include "Debug_Trace.h"
void Debug_TraceA(char* fmt, ...)
{
char buf = {0};
va_list args;
va_start( args, fmt );
vsprintf( buf, fmt, args );
va_end( args );
OutputDebugStringA( buf );
}
void Debug_TraceW(WCHAR* fmt, ...)
{
WCHAR buf = {0};
va_list args;
va_start( args, fmt );
vswprintf( buf, fmt, args );
va_end( args );
OutputDebugStringW( buf );
}
页:
[1]