MISRA.TOKEN.CPCOM.MULTILINE.2012Line-splicing used in a // comment
MISRA 2012 C Rule 3.2: Line-splicing shall not be used in // commentsCategory: Required Analysis: Decidable, Single Translation Unit Applies to: C99 AmplificationLine-splicing occurs when the \ character is immediately followed by a new-line character. If the source file contains multibyte characters, they are converted to the source character set before any splicing occurs. RationaleIf the source line containing a // comment ends with a \ character in the source character set, the next line becomes part of the comment. This may result in unintentional removal of code. Note: line-splicing is described in Section 5.1.1.2(2) of both C90 and C99. ExampleIn the following non-compliant example, the physical line containing the if keyword is logically part of the previous line and is therefore a comment. extern bool_t b; void f ( void ) { uint16_t x = 0; // comment \ if ( b ) { ++x; /* This is always executed */ } } See alsoDir 4.4 |