我收到警告
warning: multi-line comment [-Wcomment]
由于我的评论看起来像
// strings can start with a \ and also end with a \
我了解该错误并已看到有关该主题的其他 SO 消息。
我可以轻松修复警告(通过双引号\s)。
我很好奇的是,我注意确保该行不以\结尾。该行以\结尾,然后是一个空格。这是预处理器剥离我的尾随空间并因此引入警告吗?
最佳答案
在 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.
在这种情况下,最好使用 '\'
而不是 \
因为反斜杠用作符号而不是续行指示符。另一个(主观上较差的)选项是在 \
之后放置一个结束的非空白字符(例如一个点)。
关于c++ - gcc 多行注释警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46771175/