Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Do not use the character sequence /* within a comment:

Code Block
bgColor#FFcccc
/* comment with end comment marker unintentionally omitted
...
security_critical_function();
/* some other comment */

...

Comment out blocks of code using conditional compilation (e.g., #if, #ifdef), or #ifndef).

Code Block
bgColor#ccccff
#if 0  /* use of critical security function no longer necessary */
security_critical_function();
/* some other comment */
#endif

...

These are some additional examples of comment styles that are confusing and should be avoided:

Code Block
bgColor#FFcccc
// */          // comment, not syntax error
...
f = g/**//h;   // equivalent to f = g / h;
...
//\
i();           // part of a two-line comment
...
/\
/ j();         // part of a two-line comment
...
/*//*/ l();    // equivalent to l();
...
m = n//**/o
+ p;           // equivalent to m = n + p;

...

Use a consistent style of commenting:

Code Block
bgColor#ccccff
// Nice simple comment

int i; // counter

...

Use a consistent style of commenting:

Code Block
bgColor#ccccff
/* Nice simple comment */

int i; /* counter */

...