C ++单行注释,然后在多行注释\\转换 [英] C++ single line comments followed by \ transforms in multiline comment
问题描述
哪里是它在C ++标准中介绍的功能,如果该线路使用 //一些评论\\
风格(在该行看跌期权的结尾评论 \\
)的注释转化为多行?
使用g ++测试4.8和VS 2012
//一些有趣的东西\\
另一个有趣的东西\\
等等
C ++标准,2.2 - 翻译阶段。二期工程包括
一个反斜杠字符的每个实例(
\\
),紧跟着一个换行符被删除,
拼接物理源线形成逻辑源代码行。
块引用>和第三阶段包括
每个注释由一个空格字符替换
块引用>因此,在该行的末尾反斜杠评论之前的认可。
对于C相当于第二和第三阶段,可以在C标准(在我的草案5.1.1.2翻译阶段)找到。
Where is it documented in the C++ Standard the feature that if a line is commented using
//some comment\
style (at the end of the line puts\
) the comment is transformed to multiline?Tested with g++ 4.8 and VS 2012
//some interesting stuff\ another interesting stuff\ etc
解决方案C++ standard, 2.2 - phases of translation. Phase 2 includes
Each instance of a backslash character (
\
) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines.and Phase 3 includes
Each comment is replaced by one space character
So the backslash at the end of the line is recognised before comments.
Equivalent phases 2 and 3 for C can be found in C standard (5.1.1.2 Translation phases in my draft).
这篇关于C ++单行注释,然后在多行注释\\转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!