Path: utzoo!attcan!uunet!wuarchive!usc!apple!well!jef From: jef@well.sf.ca.us (Jef Poskanzer) Newsgroups: comp.lang.c++ Subject: Re: #defines.... Message-ID: <18899@well.sf.ca.us> Date: 8 Jul 90 04:41:11 GMT References: <33133@ut-emx.UUCP> Reply-To: Jef Poskanzer Organization: Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal Lines: 30 In the referenced message, petrilli@walt.cc.utexas.edu (Chris Petrilli) wrote: }The only time where you HAVE to use a #define (or at least, it is the best }way for clarity) is in conditionally compiled code. For example: } }#define DEBUG } }#ifdef DEBUG } ... (do something) ... }#endif In many systems, the optimizers are smart enough to completely eliminate code under a compile-time false if statement. As in: const int debug = 0; if ( debug ) { (do something) } Or whatever. I have not checked whether this works in any C++ system, but I have used it in numerous other systems, after checking the generated machine instructions to be sure there was no run-time overhead. One big advantage of this over using the pre-processor is that the debugging code gets syntax-checked, so you avoid bit rot. One big disadvantage is that it doesn't work on all systems, so it can't be considered portable. --- Jef Jef Poskanzer jef@well.sf.ca.us {ucbvax, apple, hplabs}!well!jef A child of 5 could understand this! Fetch me a child of 5.