Mail Archives: djgpp/1993/07/06/19:11:46
> #define TRACE 0
>
> if (TRACE) fprintf(stderr...
>
> this gets assembled as
> jmp --\
> push |
> ... |
> call fprintf |
> <-/
>
> I am compiling this with -O2 -m486. Does anyone know if there is a switch
> to eliminate the inaccessable code?
I am quite surprised that gcc does not eliminate the dead code.
However, I usually do this in one of two ways:
Way 1:
/* At the beginning of the file */
#define DEBUG
/* To print debug info */
#ifdef DEBUG
fprintf(stderr, "stuff");
#endif
In this case, I turn off debugging by commenting out the #define DEBUG.
Way 2:
/* At the beginning of the file */
#define DEBUG(s) s
/* To print debug info */
DEBUG(fprintf(stderr, "stuff"));
In this case, I turn off debugging by commenting out the "s" that is
the definition of the DEBUG macro.
In either case, if I turn off debug, the compiler doesn't even see the
debugging fprintf statements.
--
Eric Backus
ericb AT lsid DOT hp DOT com
(206) 335-2495
- Raw text -