Defining a nested single-line comment within a multi-line comment invites errors. It may lead a developer to wrongly think that the lines located
after the single-line comment are not part of the comment.
If a comment starting sequence,
//, occurs within a
/* comment, is it quite likely to be caused by a
*/ comment ending sequence.
If a comment starting sequence occurs within a
// comment, it is probably because a region of code has been commented-out using
Noncompliant Code Example
/* some comment, end comment marker accidentally omitted
// Make sure this function is called in a thread safe context
/* this comment is non-compliant */
The sequence // is permitted within a // comment.
- CERT, MSC04-C. - Use comments consistently and in a readable fashion
- MISRA C:2004, 2.3 - The character sequence /* shall not be used within a comment.
- MISRA C++:2008, 2-7-1 - The character sequence /* shall not be used within a C-style comment.
- MISRA C:2012, 3.1 - The character sequences /* and // shall not be used within a comment