I want to use the TRACE() macro to get output in the debug window in Visual Studio 2005 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?
I want to use the TRACE() macro to get output in the debug window in Visual Studio 2005 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?
In my understanding wvsprintf has problem with formatting. Use _vsnprintf (or thcar version _vsntprintf ) instead
Build your own.
trace.cpp:
trace.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. ;-)
You can try the DebugOutputString function. TRACE is only enabled in debug builds.
If you use ATL you can try ATLTRACE.
TRACE is defined in afx.h as (at least in vs 2008):
And ATLTRACE can be found in atltrace.h
Thanks to these answers I have fixed my bug :-)
Here I share my TRACE macro in C++ based on ideas from Ferruccio and enthusiasticgeek.
example:
Any improvements/suggestions/contributions are welcome ;-)