Why is this an issue?
When a line of code ends with the
\ (backslash) character, the newline character is deleted. The compiler considers the next line a
continuation of the current line, resulting in only one logical line of code.
This source code transformation, known as line-splicing, occurs during the second phase of C and C++ translation.
Several compilers have a loose implementation of line-splicing and allow whitespace after the
\ character. While this
practice was non-portable until C++23, it remains non-portable in C. Furthermore, readers can easily be confused about the meaning of these
Therefore, for portability and clarity,
\ should be immediately followed by a newline character, as in the following example.
// Compliant: there is no whitespace after the '\'
#define FOO BAR \
- S2323 - Line-splicing should not be used in "//" comments