如何在非MFC项目中使用TRACE宏?

编程入门 行业动态 更新时间:2024-10-17 11:24:46
本文介绍了如何在非MFC项目中使用TRACE宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用TRACE()宏在 Visual Studio ; 2005 在非 MFC C ++项目中,但附加的标题或库是需要?

I want to use the TRACE() macro to get output in the debug window in VisualStudio2005 in a non-MFC C++ project, but which additional header or library is needed?

有什么方法可以在调试输出窗口中输入消息吗?

Is there a way of putting messages in the debug output window and how can I do that?

推荐答案

建立自己的。

trace.cpp:

trace.cpp:

#ifdef _DEBUG bool _trace(TCHAR *format, ...) { TCHAR buffer[1000]; va_list argptr; va_start(argptr, format); wvsprintf(buffer, format, argptr); va_end(argptr); OutputDebugString(buffer); return true; } #endif

trace.h:

#include <windows.h> #ifdef _DEBUG bool _trace(TCHAR *format, ...); #define TRACE _trace #else #define TRACE false && _trace #endif

然后只是#includetrace.h设置。

then just #include "trace.h" and you're all set.

免责声明:我只是从个人项目复制/粘贴此代码,并取出一些项目特定的东西,但没有理由不应该工作。 ; - )

Disclaimer: I just copy/pasted this code from a personal project and took out some project specific stuff, but there's no reason it shouldn't work. ;-)

更多推荐

如何在非MFC项目中使用TRACE宏?

本文发布于:2023-11-17 08:44:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609503.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   如何在   MFC   TRACE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!