Adjacent character and string literal tokens

牧云@^-^@ 提交于 2019-12-24 16:28:27

问题


It's a familiar fact that in C you can write "a" "b" and get "ab". This is discussed in the C11 standard:

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.

The phrase "character and..." would seem to suggest you can get the same results by writing 'a' "b", but I've never come across that usage and GCC and the Microsoft compiler both reject it. Am I missing something?


回答1:


No, maybe we're getting a wrong meaning out of the statement made there.

Let me quote from C11, chapter §5.1.1.2, Translation phases, paragraph 6,

  1. Adjacent string literal tokens are concatenated.

Here, we don't have any confusion between char and string literals, it's clearly mentioned about string literals only.



来源:https://stackoverflow.com/questions/30664664/adjacent-character-and-string-literal-tokens

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!