简体   繁体   English

关于c99,逻辑源代码行的定义是什么?

[英]Regarding to c99, What is the definition of a logical source line?

Imagine we write this code: 假设我们编写以下代码:

printf ("testtest"
    "titiritest%s",
    " test");

Would this be according to ISO/IEC:9899 §5.1.1.2 — 2 是否符合ISO / IEC:9899§5.1.1.2— 2

Be 3 different logical source lines or would it be a single one? 是3条不同的逻辑源代码行,还是单条?

And is this 这是

2. Each instance of a backslash character (\\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. 2.立即删除每个反斜杠字符(\\)并后接换行符的情况,将物理源代码行拼接成逻辑源代码行。 Only the last backslash on any physical source line shall be eligible for being part of such a splice. 只有任何物理源代码行上的最后一个反斜杠才有资格成为此类接头的一部分。 A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before any such splicing takes place. 不为空的源文件应以换行符结尾,在进行任何此类拼接之前,不得在其后立即加上反斜杠字符。

the only rule mentioned about forming logical source lines? 关于形成逻辑源线提到的唯一规则?

As regarding to the 至于

5.2.4.1 Translation limits 5.2.4.1翻译限制

[...] [...]

— 4095 characters in a logical source line —逻辑源代码行中的4095个字符

Would mean each translation unit should not get bigger as 4095 characters, as long we dont use a \\ right before our line breaks. 这就意味着,只要我们在换行符前不使用\\ ,每个翻译单元的大小就不应超过4095个字符。 And I'm pretty sure, thats not what they intend to say. 我很确定,那不是他们要说的。

So where is the piece of the definition I'm missing to lookup? 那么我缺少查找的定义在哪里?

It's three logical source lines. 这是三个逻辑源代码行。

Logical source lines are mostly important because macro definitions must fit into one logical source line; 逻辑源代码行最重要,因为宏定义必须适合一个逻辑源代码行; I cannot right now think of any other use for logical source lines of more than one line. 我现在无法想到逻辑源代码行多于一行的其他用途。 To construct large string literals, you could either use logical source lines consisting of more than one physical source line (which I personally find very ugly), or relying on the fact that quoted strings will be concatenated, which is much more readable and maintainable . 要构造大型字符串文字,您可以使用由多个物理源代码行组成的逻辑源代码行(我个人觉得非常丑陋),也可以依靠将引用的字符串连接在一起的事实,这更加可读和可维护。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM