1

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?

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
rwallace
  • 31,405
  • 40
  • 123
  • 242
  • 1
    I think it should be read "character string literal", not "character literal". – Alex Shesterov Jun 05 '15 at 10:51
  • 1
    The complete para is *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. If any of the tokens has an encoding prefix, the resulting multibyte character sequence is treated as having the same prefix; otherwise, it is treated as a character string literal. Whether differently-prefixed wide string literal tokens can be concatenated and, if so, the treatment of the resulting multibyte character sequence are implementation-defined.* and.. – P.P Jun 05 '15 at 10:55
  • 1
    And it's also under section *6.4.5 String literals*. So it's rather obvious that the standard refers to character string literals, not character literals. – P.P Jun 05 '15 at 10:56
  • I believe it should be interpreted as "any sequence of adjacent *character string literal* tokens and *identically-prefixed string literal* tokens." It's a very confusing contraction. – molbdnilo Jun 05 '15 at 11:15

1 Answers1

3

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.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261