c++ - How can I use the TRACE macro in non-MFC projects? -


I want to use the TRACE () macro to get the output in the debug window in non-C ++ project, But what additional headlines or libraries are needed?

Is the debug output method a way to enter messages and how can I do this?

create your own.

trace.cpp:

  #ifdef _DEBUG bool _trace (TCHAR * format, ...) {TCHAR buffer [1000]; Va_list argent; Va_start (argent, format); Wvsprintf (buffer, format, ergroup); Va_end (argptr); OutputDebugString (buffer); Back true; } #endif  

trace.h:

  #include & lt; Windows.h & gt; #ifdef _DEBUGBull _trace (TCHAR * format, ...); #define TRACE _trace #else #define TRACE false & amp; Amp; _trace #endif  

Just include "trace.h" and you are all set.

Disclaimer: I only copy / past this code from a private project and took some project specific items, but there is no reason that this should not work. ; -)


Comments