Re: evaluating #defines in gdb?

From: Trey T. Morita (tmorita@texas.net)
Date: 11/02/95


On Thu, 2 Nov 1995, Mark Devlin wrote:
> gdb (and other source-level debuggers) get the info about variables from 
> the symbol table in the executable.  When you compile with debug info, 
> one of the things the compiler does is store the file and line number of a 
> variable/function so the debugger could find it easily.  Note that this 
> is what the _compiler_ does, NOT the preprocessor (which deals with the 
> #defines, #includes, etc before the compiler even sees them).  The 
> preprocessor would need to be modified to pass the macros on to the 
> compiler, which would need to be changed to deal with it.  Too much 
> hassle for too little benefit.
> 
> The alternative?  If you're using an ANSI C compiler (which I'm pretty 
> sure you have to be to be compiling Circle, if I remember correctly), use 
> things like:
> const int MAX_RACES = 6;
> 
> Some compilers will allocate memory for a variable, others will 
> just insert the value just as the preprocessor does with #defines.  
> However, most (if not all) debuggers will be able to evaluate 
> "MAX_RACES".
> 
> Another alternative that will work (I think) is to use enums:
> enum { MAX_RACES = 6 };
> 
Thanks for the info Mark, but the part that got clipped (the original 
mail by me) was using an example of GET_STR(ch) which is in actuality . . 
#define GET_STR(ch)     ((ch)->aff_abils.str)
There's no real way to sub a const declaration for this, now, is there?

Trey



This archive was generated by hypermail 2b30 : 12/07/00 PST