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

我们知道,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.

原文地址:https://www.cnblogs.com/lidabo/p/2837545.html