home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22100 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  1.5 KB

  1. Path: sparky!uunet!usc!davidp
  2. From: davidp@stealth.usc.edu (David Peterson)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Porting code from UNIX: how to get rid of printfs
  5. Date: 24 Jan 1993 19:16:14 -0800
  6. Organization: University of Southern California, Los Angeles, CA
  7. Lines: 32
  8. Distribution: world
  9. Message-ID: <1jvm1uINN30g@stealth.usc.edu>
  10. References: <C1DCus.B0q@cs.uiuc.edu>
  11. Reply-To: davidp@usc.edu
  12. NNTP-Posting-Host: stealth.usc.edu
  13. Keywords: unix, porting
  14.  
  15.  
  16. In article <C1DCus.B0q@cs.uiuc.edu>, totic@milton.cs.uiuc.edu (Aleksandar Totic) writes:
  17. |> Hello,
  18. |> I am using some UNIX code on the Mac. It works fine, with the exception
  19. |> that occasionally the code uses printf to print diagnostics and errors.
  20. |> Currently I am using Think C, but soon I`ll port it to MacApp also.
  21. |> The result of printf in ThinkC is to pop up a console window. Is there
  22. |> any way to get rid of this behaviuor, maybe pipe the statements into
  23. |> dialog boxes, or my own error window? All comments are welcome, I do 
  24. |> not know if there is a right answer to this.
  25. |> 
  26.  
  27. You could define a macro that re-routes it to MacsBug. Its really annoying,
  28. but it works great for debugging diagnostics.
  29.  
  30. #define printf MBPrintf
  31. void MBPrintf(char* form, ...)
  32. {
  33.     va_list ap;
  34.     char    str[256];
  35.  
  36.     va_start(ap, form);
  37.     vsprintf(str, form, ap);
  38.     va_end(ap);
  39.     DebugStr(c2pstr(str));
  40. }
  41.  
  42. If you want to jump into MacApp, just compile it with one of the debug
  43. libraries and printf's will get sent to a window in SourceBug if you have
  44. it running. Sort of a neat concept.
  45.  
  46. -dave.
  47.