22.1 C/C++ Language Comments
A C/C++ comment is ignored by the compiler and can be used to provide information to someone reading the source code. They should be used freely.
Comments may be added by enclosing the desired characters within /*
and
*/
. The comment can run over multiple lines, but comments cannot be
nested. Comments can be placed anywhere in C/C++ code, even in the middle of
expressions, but cannot be placed in character constants or string literals.
Since comments cannot be nested, it may be desirable to use the #if
preprocessor directive to comment out code that already contains comments, for
example:
#if 0
result = read(); /* TODO: Jim, check this function is right */
#endif
Single-line, C++ style comments may also be specified. Any characters following // to the end of the line are taken to be a comment and will be ignored by the compiler, as shown below:
result = read(); // TODO: Jim, check this function is right