G
Giff
Hi again,
I need a suggestion.
Right now I am developing an application and I want to be able to
output on screen some variables. Anyway, I want to remove these output
operations when passing on the implementation of another function or
finiship up the program etc.. Still I whish to be able to have the
output again in case I will need to do some debugging in the future
(very likely!).
Now I pass to each function a bool parameter "show" and then, inside
the function:
if(show) output some stuff.
I suppose that this if-statement slows down the code a lot (and the
program MUST be fast), for instance because the compiler cannot
optimize not knowing the value of the show flag at runtime. Is that
correct?
What is the best way then to have this control over debugging output?
Should I use the preprocessor with a #define and then #ifdef /
#ifndef?
I'm happy to learn
I need a suggestion.
Right now I am developing an application and I want to be able to
output on screen some variables. Anyway, I want to remove these output
operations when passing on the implementation of another function or
finiship up the program etc.. Still I whish to be able to have the
output again in case I will need to do some debugging in the future
(very likely!).
Now I pass to each function a bool parameter "show" and then, inside
the function:
if(show) output some stuff.
I suppose that this if-statement slows down the code a lot (and the
program MUST be fast), for instance because the compiler cannot
optimize not knowing the value of the show flag at runtime. Is that
correct?
What is the best way then to have this control over debugging output?
Should I use the preprocessor with a #define and then #ifdef /
#ifndef?
I'm happy to learn