www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/07/06/22:12:08

Date: Wed, 7 Jul 93 11:02:47 JST
From: Stephen Turnbull <turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Eliminating dead code

Yes,
#if(TRACE)
    // code you only want some of the time
#endif
IS obvious.
    However, I once had a fairly complicated interactive program which
I debugged in two stages:
    Stage 1:  Use the *variable* TRACE to interactively turn on tracing
              when something strange happened.
    Stage 2:  Comment out the the declaration of TRACE and use the
              *macro* TRACE to determine whether debugging code was
              included (Zortech C/C++ *does* eliminate such dead code).
              This was done to make sure that old modules weren't broken 
              as new ones were added and induced erratic behavior in the
              system.
Since there were lots of places where the TRACE switch was used, it would
have been very inconvenient to change from `if(TRACE){}' to `#if(TRACE) 
... #endif'.
    So if GNU C/C++ does *not* eliminate this dead code, I would consider 
it a misfeature.
    --Steve

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019