cb9 Keeping Deleted Code for Future Reference Contents|Index|Previous|Next
 

Keeping deleted code for future reference 

If you replace or delete a part of the program but want to keep the old code around as a comment for future reference, the easy way to do this is to put #if 0 before it and #endif after it. This is better than using comment delimiters /* and */ since those won’t work if the code already contains comments (C comments do not nest).

This works even if the code being turned off contains conditionals, but they must be entire conditionals (balanced #if and #endif).

Conversely, do not use #if0 for comments which are not C code. Use the comment delimiters /* and */ instead. The interior of #if0 must consist of complete tokens; in particular, single quote characters must balance. But comments often contain unbalanced single quote characters (known in English as apostrophes). These confuse #if0. They do not confuse /*. 0