When CPP line splicing is canceled in C ++ 0x source strings, is an appropriate implementation necessary to maintain the original string sequence?

The latest C ++ 0x, n3126 project says:

Each instance of the backslash character (\) immediately followed by a newline character is deleted by splicing the physical source lines to form the logical lines of the source.

...

Inside the r-char sequence of the original string literal, any transformations performed in phases 1 and 2 (trigraphs, universal character names, and linear splices) are returned.

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

Is C ++ 0x implementations required to preserve a newline sequence that immediately follows the backslash character \ within the r-char sequence of the original string? Perhaps the best question is: was it expected from the Windows C ++ 0x compiler to cancel each line splicing using "\\\r\n" instead of "\\\n" ?

+6
c ++ c-preprocessor c ++ 11 rawstring
source share
2 answers

The translation phase begins with

The characters of the physical source file are mapped, in a manner defined by the implementation, to the main character of the source set (input of newline characters for end of line indicators), if necessary. the trigraph of the sequence (2.3) is replaced [...]

I would interpret the requirement "any transformations performed in phases 1 and 2 (trigraphs, universal symbol names and line splicing)" as clearly not returning the transformation from the characters of the source file to the main character set of the source. Instead, the original characters are later converted to a set of execution characters, and you get newline characters.

+4
source share

If you need a specific line ending sequence, you can insert it explicitly and use string literal concatenation:

 char* nitpicky = "I must have a \\r\\n line ending!\r\n" "Otherwise, some other piece of code will misinterpret this line!"; 
0
source share

All Articles