...
Do not use the character sequence /* within a comment:
| Code Block | ||
|---|---|---|
| ||
/* 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 | ||
|---|---|---|
| ||
#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 | ||
|---|---|---|
| ||
// */ // 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 | ||
|---|---|---|
| ||
// Nice simple comment int i; // counter |
...
Use a consistent style of commenting:
| Code Block | ||
|---|---|---|
| ||
/* Nice simple comment */ int i; /* counter */ |
...