BrendaEM:
putting any IF statement in a program will not make it any faster.
The compiler is smart enough to just remove any code after an if(false) since it knows it will never be used so yes it does run faster and uses less memory when DEBUG is set to false then it does when DEBUG is set to true.
BrendaEM:
Are we not supposed to use const rather than #define?
BrendaEM:
Are we not supposed to use const rather than #define?
I assume you mean doing:
const boolean DEBUG=false;
instead of:
#define DEBUG false
Yes, that should work fine for the most part. I also try to use the preprocessor as infrequently as possible but there are some applications where DEBUG being a macro could be useful. For example, I usually do this so I don't forget to turn debug output off when I'm not using it:
#if DEBUG == true
#warning Debug output is on
#endif
That doesn't work if I use const instead of a macro.