Jump to content
  • Advertisement
Sign in to follow this  
azherdev

[Win32 C++] How do I write to the "Output" window in Visual Studio 2005?

This topic is 4063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I am going crazy here. Does anyone know how to write a string to the "Output" window in Visual Studio 2005 C++ Win32 project? Not using ATL. Thank you folks.

Share this post


Link to post
Share on other sites
Advertisement
The function OutputDebugString does that for you.
Note that it does not accept a printf-like formatting, so you need to pass whole strings to it.

Share this post


Link to post
Share on other sites
Thank you guys. But what about this TRACE macro? Where is it defined? Does the OutputDebugString go away in the release build?

Share this post


Link to post
Share on other sites
TRACE is an MFC macro and it does the same thing as OutputDebugString except you can use printf style formatting.

I'm fairly certain these functions only work in debug builds.

Share this post


Link to post
Share on other sites
Quote:
Original post by azherdev
Thank you guys. But what about this TRACE macro? Where is it defined? Does the OutputDebugString go away in the release build?
Right click on TRACE in MSVC and click "Go to definition". It's probably a function that calls OutputDebugString.

From my code:

#include <windows.h>
#include <stdio.h>

void PLog::DebugFormat(const char* szFormat, ...)
{
char szBuff[1024];
va_list arg;
va_start(arg, szFormat);
_vsnprintf(szBuff, sizeof(szBuff), szFormat, arg);
va_end(arg);

OutputDebugString(szBuff);
}


And OutputDebugString() does not go away in Release builds, you'll have to wrap it in a macro to do that. Random fact: GTA2 is actually compiled with a few OutputDebugStrings in it. At least they show up in the function import table.

Share this post


Link to post
Share on other sites
Also, if you are writing code for a CObject derivative class, you can used the CDumpContext reference 'afxDump' ie afxDump << "Going to debug window" << this;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!