且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将C++调试信息显示在VS输出窗口中, 像TRACE一样调用

更新时间:2022-06-21 03:58:21

我们知道,MFC中可以调用宏TRACE等十分方便的输出调试信息到Visual Studio输出窗口,但C++中没人类似的函数,最近我在开发一个小程序时跟踪了一下MFC的TRACE宏,发现它映像了atltrace.h中的ATLTRACE宏,因些,我们也想在C++中使用TRace可以用如下方式:

#include <atltrace.h>
#define TRACE ATLTRACE

TRACE("");

在C++中可以直接使用下面的函数

OutputDebugString Function

 

Sends a string to the debugger for display.

 

Syntaxvoid WINAPI OutputDebugString( __in_opt LPCTSTR lpOutputString); Parameters
lpOutputString

The null-terminated string to be displayed.

Return Value

This function does not return a value.