[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GSBug Trick #1 (was Re: ORCA/C advice needed)
In article <1993Mar22.163144.22543@cs.UAlberta.CA> glyn@cs.UAlberta.CA (Reade Glyn Devin) writes:
>In article <jmk3.732437924@crux1.cit.cornell.edu>, jmk3@crux3.cit.cornell.edu (Jay Krell) writes:
>> #define debugstrings
>> #ifndef debugstrings
>> #undef DebugStr
>> #undef SetMileStone
>> pascal void SetMileStone(Pointer) {}
>> pascal void DebugStr(Pointer) {}
>> #endif
>>
>> #define debugstrings while in development and remove it when done.
>
>While this is good when you want to see a working copy without the debug
>code in it, it has the problem of spending cpu time and stack space on
>calls to null functions.
>
>Another alternative [...]
#ifdef DEBUG
#define DBUG(x) DebugStr x
#else
#define DBUG(x)
#endif
Then write something like:
DBUG(("fubar"));
This also works with something like printf() (which is how it's usually used).
You can do:
#define DBUG(x) printf x
DBUG(("%d fubar %d %s", 1, 2, "ack"));
and have it completely removed when you stop defining DEBUG. No null
functions, no sed scripts.
--
fadden@uts.amdahl.com (Andy McFadden)
[ Above opinions are mine, Amdahl has nothing to do with them, etc, etc. ]