Reputation: 6916
I'm getting a warning
warning: multi-line comment [-Wcomment]
due to a comment that I have that looks something like
// strings can start with a \ and also end with a \
I understand the error and have seen other SO messages on the subject.
I can easily fix the warning (by double quoting the \s).
What I'm curious about is that I took care to make sure that the line does not end with a \. The line ends with \ and then a space. Is this the preprocessor stripping my trailing space and thereby introducing the warning?
Upvotes: 3
Views: 3977
Reputation: 4214
During the initial processing preprocessor performs a series of textual transformations on its input.
Here's the quote from the docs (relevant piece is in bold):
Continued lines are merged into one long line.
A continued line is a line which ends with a backslash, . The backslash is removed and the following line is joined with the current one.
...
The trailing backslash on a continued line is commonly referred to as a backslash-newline.
If there is white space between a backslash and the end of a line, that is still a continued line. However, as this is usually the result of an editing mistake, and many compilers will not accept it as a continued line, GCC will warn you about it.
In this case it is best to use '\'
instead of \
as backslash is used as a symbol and not as a continued-line indicator. Another (subjectively inferior) option is to put an ending non-whitespace character after \
(for example a dot).
Upvotes: 4