Previous: , Up: Comments   [Contents][Index]


6.3 Temporary comments

During development, one frequently desires to temporarily comment out a section of code. C programmers sometimes try to do this by enclosing the code in /*...*/, but this is not good style for several reasons. First, it is impossible if the code itself includes comments, since comments do not nest in C. Second, FWEAVE will treat the commented code as TeX rather than C code and will (at best) format it very poorly. In fact, LaTeX will frequently complain, because the commented code might contain characters such as underscores that TeX expects to be in math mode. (Those are dealt with automatically when FWEAVE is in code mode.) The trivial example ‘/* a_b; */ is sufficient to illustrate this point.

The proper way of commenting out sections of code is to use preprocessor constructions: #if 0...#endif in C, or more generally @#if 0...@#endif (usable in all languages). (The FWEB preprocessor is described in Preprocessing.) With this method, there is no trouble with nested comments, and FWEAVE will continue to format the code as code, so the documentation will make sense.

For FORTRAN programmers converting an existing code to FWEB, the ‘-nC’ option (see -nC) may be helpful.