SEC37.hss 1.3 KB

1234567891011121314151617181920212223242526
  1. [Main]
  2. Title=Deleted Code
  3. [Top]
  4. If you replace or delete a part of the program but want to keep the old
  5. code around for future reference, you often cannot simply comment it
  6. out. Block comments do not nest, so the first comment inside the old
  7. code will end the commenting-out. The probable result is a flood of
  8. syntax errors.
  9. <BR><BR>
  10. One way to avoid this problem is to use an always-false conditional
  11. instead. For instance, put <CODE>#if&nbsp;0</CODE> before the deleted code and
  12. <CODE>#endif</CODE> after it. This works even if the code being turned
  13. off contains conditionals, but they must be entire conditionals
  14. (balanced <CODE>#if</CODE> and <CODE>#endif</CODE>).
  15. <BR><BR>
  16. Some people use <CODE>#ifdef&nbsp;notdef</CODE> instead. This is risky, because
  17. <CODE>notdef</CODE> might be accidentally defined as a macro, and then the
  18. conditional would succeed. <CODE>#if&nbsp;0</CODE> can be counted on to fail.
  19. <BR><BR>
  20. Do not use <CODE>#if&nbsp;0</CODE> for comments which are not C code. Use a real
  21. comment, instead. The interior of <CODE>#if&nbsp;0</CODE> must consist of complete
  22. tokens; in particular, single-quote characters must balance. Comments
  23. often contain unbalanced single-quote characters (known in English as
  24. apostrophes). These confuse <CODE>#if&nbsp;0</CODE>. They don't confuse
  25. <CODE>/*</CODE>.