gcc 多行注释警告
gcc multi line comment warning
我收到警告
warning: multi-line comment [-Wcomment]
由于我的评论看起来像
// strings can start with a \ and also end with a \
我理解这个错误并且看到了关于该主题的其他 SO 消息。
我可以轻松修复警告(通过双引号 \s)。
我很好奇的是,我小心翼翼地确保 行没有 以 \ 结尾。该行以 \ 结尾,然后是 space。这是预处理器剥离我的尾随 space 并因此引入警告吗?
在 initial processing 期间,预处理器对其输入执行一系列文本转换。
引用自文档(相关部分以粗体显示):
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.
在这种情况下,最好使用 '\'
而不是 \
,因为反斜杠用作符号而不是续行指示符。另一个(主观上较差的)选项是在 \
之后放置一个结束的非空白字符(例如一个点)。
我收到警告
warning: multi-line comment [-Wcomment]
由于我的评论看起来像
// strings can start with a \ and also end with a \
我理解这个错误并且看到了关于该主题的其他 SO 消息。
我可以轻松修复警告(通过双引号 \s)。
我很好奇的是,我小心翼翼地确保 行没有 以 \ 结尾。该行以 \ 结尾,然后是 space。这是预处理器剥离我的尾随 space 并因此引入警告吗?
在 initial processing 期间,预处理器对其输入执行一系列文本转换。
引用自文档(相关部分以粗体显示):
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.
在这种情况下,最好使用 '\'
而不是 \
,因为反斜杠用作符号而不是续行指示符。另一个(主观上较差的)选项是在 \
之后放置一个结束的非空白字符(例如一个点)。