1.3 Comments

The /* character combination introduces a comment and the */ character combination ends a comment, except within a character constant or string literal.

Comments cannot be nested; once a comment is started, the compiler treats the first occurrence of */ as the end of the comment.

To comment out sections of code, avoid using the /* and */ sequences. Using the /* and */ sequences works only for code sections containing no comments, because comments do not nest. A better method is to use the #if and #endif preprocessor directives, as in the following example:

#if 0
/*  This code is excluded from execution because ...  */
code_to_be_excluded ();
#endif

See Chapter 8 for more information on the preprocessing directives #if and #endif .

Comments cannot span source files. Within a source file, comments can be of any length and are interpreted as white space by both the compiler and the preprocessor.


Previous Page | Next Page | Table of Contents | Index