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