cpp: Deleted Code
1
1 4.3 Deleted Code
1 ================
1
1 If you replace or delete a part of the program but want to keep the old
1 code around for future reference, you often cannot simply comment it
1 out. Block comments do not nest, so the first comment inside the old
1 code will end the commenting-out. The probable result is a flood of
1 syntax errors.
1
1 One way to avoid this problem is to use an always-false conditional
1 instead. For instance, put '#if 0' before the deleted code and '#endif'
1 after it. This works even if the code being turned off contains
1 conditionals, but they must be entire conditionals (balanced '#if' and
1 '#endif').
1
1 Some people use '#ifdef notdef' instead. This is risky, because
1 'notdef' might be accidentally defined as a macro, and then the
1 conditional would succeed. '#if 0' can be counted on to fail.
1
1 Do not use '#if 0' for comments which are not C code. Use a real
1 comment, instead. The interior of '#if 0' must consist of complete
1 tokens; in particular, single-quote characters must balance. Comments
1 often contain unbalanced single-quote characters (known in English as
1 apostrophes). These confuse '#if 0'. They don't confuse '/*'.
1