Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When CPP line splicing is undone within C++0x raw strings, is a conforming implementation required to preserve the original newline sequence?

The latest draft of C++0x, n3126, says:

Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines.

...

Within the r-char-sequence of a raw string literal, any transformations performed in phases 1 and 2 (trigraphs, universal-character-names, and line splicing) are reverted.

Technically this means that the C++ preprocessor only recognizes a backslash followed by the newline character, but I know that some C++ implementations also allow Windows- or classic Mac-style line endings as well.

Will conforming implementations of C++0x be required to preserve the newline sequence that immediately followed a backslash character \ within the r-char-sequence of a raw string? Maybe a better question is: would it be expected of a Windows C++0x compiler to undo each line splice with "\\\r\n" instead of "\\\n"?

like image 229
Daniel Trebbien Avatar asked Dec 27 '10 17:12

Daniel Trebbien


1 Answers

Translation phase 1 starts with

Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set (introducing newline characters for end-of-line indicators) if necessary. Trigraph sequences (2.3) are replaced [...]

I'd interpret the requirement "any transformations performed in phases 1 and 2 (trigraphs, universal-character-names, and line splicing)" as explicitly not reverting the transformation from source file characters to the basic source character set. Instead, source characters are later converted to the execution character set, and you get newline characters there.

like image 155
Martin v. Löwis Avatar answered Sep 21 '22 10:09

Martin v. Löwis