This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Debug, DEBUGGING and stuff


Erik Sigra wrote:
> 
> >From misc.h:
> /* If the debug flag is not a macro, then declare it as a global. */
> #ifndef Debug
> extern int Debug;
> #endif
> 
> What is the rationale for having this stuff? Why have global and macro? Why
> have both DEBUGGING and Debug? Is there an overview of how this debug stuff
> is designed?

What, you mean it's not obvious? :-)

DEBUGGING is a general ifdef that you can tweak in config.h to drop
out of all the debugging-related code.  It's probably a bit of an
anachronism nowadays - at the time it went in one had to be more
conscious of memory footprint, even for code.  The DESIGNERS macro
has a similar motivation, and indeed at one time (in 5.x) there was
also a sort of game compiler that could specialize an executable to a
particular game design.  (It was never used, so I dropped it.)

So if debugging code is in, you need global flags you can turn on and
off, thus Debug and friends.  But if debugging code is out, then you
want to whack out things like "if (Debug) { ... }".  One way is to
surround each with #ifdef DEBUGGING/#endif pairs, but that clutters
up the code.  So instead we make Debug a macro that expands to 0,
and the compiler is happy to drop "if (0) { ... }" constructs.

Just for grins, I tried undefining DEBUGGING for the first time in
many moons.  It drops 34K from an 884K text section in sdlconq, and
similarly for xconq's 962K text section.  Underwhelming...

Stan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]