相邻的字符和字符串文字标记
Adjacent character and string literal tokens
众所周知,在 C 中您可以编写 "a" "b"
并得到 "ab"
。这在 C11
标准中讨论:
In translation phase 6, the multibyte character sequences specified by any sequence of adjacent character and identically-prefixed string literal tokens are concatenated into a single multibyte character sequence.
短语 "character and..." 似乎暗示您可以通过编写 'a' "b"
获得相同的结果,但我从未遇到过这种用法,GCC 和 Microsoft 编译器都拒绝它。我错过了什么吗?
不,也许我们从那里所做的陈述中得到了错误的意思。
让我引用 C11
,章节 §5.1.1.2,翻译阶段 ,第 6 段,
- Adjacent string literal tokens are concatenated.
在这里,我们不会混淆char
和string字面量,关于string字面量已经明确提到只有.
众所周知,在 C 中您可以编写 "a" "b"
并得到 "ab"
。这在 C11
标准中讨论:
In translation phase 6, the multibyte character sequences specified by any sequence of adjacent character and identically-prefixed string literal tokens are concatenated into a single multibyte character sequence.
短语 "character and..." 似乎暗示您可以通过编写 'a' "b"
获得相同的结果,但我从未遇到过这种用法,GCC 和 Microsoft 编译器都拒绝它。我错过了什么吗?
不,也许我们从那里所做的陈述中得到了错误的意思。
让我引用 C11
,章节 §5.1.1.2,翻译阶段 ,第 6 段,
- Adjacent string literal tokens are concatenated.
在这里,我们不会混淆char
和string字面量,关于string字面量已经明确提到只有.