When are whitespace significant in translation phases 5 and 6 in C language?

To recap, the phases 5-7 are described in the standard:

  • Each source character set member and escape sequence in character constants and string literals is converted to the corresponding member of the execution character set; if there is no corresponding member, it is converted to an implementation- defined member other than the null (wide) character. 7)
  • Adjacent string literal tokens are concatenated.
  • White-space characters separating tokens are no longer significant. Each preprocessing token is converted into a token. The resulting tokens are syntactically and semantically analyzed and translated as a translation unit.
  • Now I agree that whites-space characters are no longer significant at phase 7, but couldn't one get rid of them already after phase 4? Is there an example where this would make a difference?

    Of course it should be realized that removing white-space characters separating tokens doesn't work at this stage as the data after phase 4 consists of preprocessing tokens . The idea is to get rid of spaces separating preprocessing tokens at an earlier stage.


    Consider this source code

    char* str = "some text"   " with spaces";
    

    In phase 5 this is converted to these tokens (one token per line):

    char
    *
    str
    =
    "some text"    
    " with spaces"
    

    Here matter the spaces in "some text" and " with spaces".

    Afterwards all spacees between tokens (see above) are ignored.

    If you remove whitespace before step 5 you get other string literals like "sometext"

    链接地址: http://www.djcxy.com/p/73292.html

    上一篇: 关于C语言预处理之前的翻译阶段的困惑

    下一篇: 在C语言的翻译阶段5和6中,什么时候空白显着?