Where is my good old printf? 
Author Message
 Where is my good old printf?

Ok,

when I write a Windows Based application ( Win32 application ) it's
sometimes usefuls to produce somes debug output.  In a Console Based
Application, there the standard output generated by printf or cout...but
what if I want to do that in Win32 application?

Steeve



Mon, 24 Sep 2001 03:00:00 GMT  
 Where is my good old printf?

   > when I write a Windows Based application ( Win32 application ) it's
   > sometimes usefuls to produce somes debug output.  In a Console Based
   > Application, there the standard output generated by printf or cout...
   > but what if I want to do that in Win32 application?

Use wsprintf() (from Win32 API) or sprintf() (from C runtime) to build the
string, then use OutputDebugString() to print it to the debug output (which
will show up in the IDE's debug pane).  Make sure to place this code in a
conditional block (i.e., #ifdef _DEBUG ... #endif) so that it is only
present in the debug build.

--
C l o s e  t h e  w o r l d , t x E n  e h t  n e p O



Mon, 24 Sep 2001 03:00:00 GMT  
 Where is my good old printf?
if your using MFC you can use the "TRACE" macro, or in a MFC or non-MFC
application you can you "OutputDebugString"

In both cases the output will be displayed in the de{*filter*}s output window

--
Visit: http://www.*-*-*.com/



Mon, 24 Sep 2001 03:00:00 GMT  
 Where is my good old printf?

Quote:
>will show up in the IDE's debug pane).  Make sure to place this code in a
>conditional block (i.e., #ifdef _DEBUG ... #endif) so that it is only
>present in the debug build.

Doesn't really matter...unless you are concerned with code size or are just
meticulous. However, having OutputDebugStrings present in a release version
is a fantasic (read: cheap and easy) way of debuggng a deployed application
or service exe (get the DbgView from sysinternals.com to read the output).

greg



Tue, 25 Sep 2001 03:00:00 GMT  
 Where is my good old printf?
The driver for my sound card has OutputDebugString calls left in it and I
am not amused.

Each time I start up an application that links in AVI files (or any other
multi-media DLL that causes the sound driver to be loaded) I'm treated to
several hundred lines of startup diagnostics.

Very annoying, and it looks very unprofessional.

In short, if you leave OutputDebugString calls in your released program/
DLL/service, make them be disabled under normal circumstances, or else
you will anger other developers.

This is particularly true of any developers that are using something like
DBWin32 to globally view OutputDebugString - spewing your random
debug information into the global debug space is rude.

Luckily it's easy to make OutputDebugString behave politely. Don't
call it directly - instead write a dprintf() function (optionally taking
printf style formatting) and have it check a command line option or
registry setting before printing. It's convenient, non-annoying, and
very effective.

Quote:

> >will show up in the IDE's debug pane).  Make sure to place this code in a
> >conditional block (i.e., #ifdef _DEBUG ... #endif) so that it is only

> >present in the debug build.

> Doesn't really matter...unless you are concerned with code size or are just
> meticulous. However, having OutputDebugStrings present in a release version
> is a fantasic (read: cheap and easy) way of debuggng a deployed application
> or service exe (get the DbgView from sysinternals.com to read the output).

> greg

--
.Bruce Dawson, Cavedog Entertainment.
Makers of Total Annihilation - http://www.cavedog.com


Tue, 25 Sep 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. how good am I? Am I Good Enough????

2. replacing printf with my printf, then calling C lib's printf

3. The good old Hashing function

4. The good old ctrl-c problem...

5. HELP!: Anyone remember good old ON_GOTO?

6. Good old Quake 2 question

7. I am new to programming and am lost

8. (void)printf() vs. printf()

9. Re(2): Re(2): (void)printf() vs. printf()

10. Re(2): (void)printf() vs. printf()

11. Is STL really list really better than good old linked lists?

12. Help: I am desire for source code of function "printf()"

 

 
Powered by phpBB® Forum Software