TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DARIN MCBRIDE
from: ERIK WARMELINK
date: 1997-08-11 00:51:00
subject: Sunir ventures into C++

Darin, 09 Aug you wrote to me:
 DM> char szBuf[128];
 DM> sprintf(szBuf, "...", ...);
 DM> WinMessageBox(HWND_DESKTOP, szBuf, "function name", MB_OK,
 DM> ...) 
 EW> Wouldn't
 EW> dbg("function name", ..., "...", ...); 
 EW> be easier? Perhaps even
 DM> Heck, no.  That would require writing a dbg function! 
It wouldn't be much larger than the snippet you posted.
 void dbg(const char function[], type1 arg1, const char format[], ...) {
     va_list va;
     char buf[128];
     va_start(va, format);
     vsprintf(buf, format, va);
     WinMessageBox(HWND_DESKTOP, buf, function, MB_OK, arg1);
     va_end(va);
 }
Not something I would call a requirement. ;-)
 DM> Sometimes I just need a quick peek, not a full-fledged
 DM> debugging system.  
With the above function it would require only one line, not three. 
 EW> dbg(number, "function name", ...);
 EW> where number is a switch that can be put on from the command line. The
 EW> debug code could again be useful later. ;-)
 DM> Again, that's if I have time to develop a full-fledged
 DM> debugging system into my code.  I don't always have that
 DM> luxury.
Just add
     if (number != interesting_debug)
         return;
to the function and add code to recognize the appropiate commandline switch. 
Again, it won't take significant time.
Bye,
 Erik 
---
---------------
* Origin: WarmelinkE@vertis.nl (2:282/1.60)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.