views:

73

answers:

3

What is the standard macro used to write text to the output window in Win32 (outside MFC)? I am looking for something which the pre-processor conditionally excludes from the release build.

(This might sound like SO sacrilege but I've merely forgotten this one and there was too much noise on Google. We are on the verge of handcrafting our own.)

+2  A: 

I don't believe there's a standard, best to roll your own.

However, you might want to consider OutputDebugString(char*). It'll send output to the debug channel.

Steve Lacey
OutputDebugString calls would not be eliminated by preprocessor.
ssg
Yes, but you could use OutputDebugString() in the macro...
Steve Lacey
+1  A: 

There is a trace macro for this, which is a debug-only printf-style output function. Besides that, you might want to give the _RPT macros a try.

Anteru
TRACE is MFC only. But thanks for the _RPT* macros.
Vulcan Eager
Damn, missed the "non-MFC" solution :D You might want to take a look at how the macro is implemented though, maybe it does not use MFC internally at all.
Anteru
A: 

Maybe you're thinking of ATLTRACE? Not quite "the standard macro", but pretty close, I guess.

Arnout
Does it work with plain Win32?
Vulcan Eager
Sure. I just created a Win32 console project, included atlbase.h, and the ATLTRACE() output is nicely appearing in the output window.
Arnout