I usually debug my programs using print statements ( redirected to a log file). 
I place a #define _DEBUG at the top and place all the print statement between a #ifdef _DEBUG and #endif so that once I am convinced that program is running correctly I can change the #define and none of the print statements appear anymore.
The only disadvantage is that with all #ifdefs in the program, it is not at all readable because #ifdefs start from the beginning of the line. 
Is there a way I can remove all the #ifdef,#endif and also all the lines between them ?
I can do this using recording if there are same number of print statements between define condition.
 
     
     
     
    