c - 关于c99,逻辑源行的定义是什么?

标签 c c99

想象一下我们编写这段代码:

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

这是否符合 ISO/IEC:9899 §5.1.1.2 — 2

是 3 个不同的逻辑源代码行还是单个逻辑源代码行?

这是吗

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. 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.

关于形成逻辑源代码行提到的唯一规则?

关于

5.2.4.1 Translation limits

[...]

— 4095 characters in a logical source line

这意味着每个翻译单元不应变得更大为 4095 个字符,只要我们不在换行符之前使用 \ 即可。我很确定,这不是他们想要说的。

那么我缺少查找的定义部分在哪里?

最佳答案

这是三个逻辑源代码行。

逻辑源代码行非常重要,因为宏定义必须适合一个逻辑源代码行;我现在无法想到多于一行的逻辑源代码行的任何其他用途。要构造大型字符串文字,您可以使用由多个物理源代码行组成的逻辑源代码行(我个人认为这非常丑陋),或者依赖于引用的字符串将被连接这一事实,这更具可读性和可维护性。

关于c - 关于c99,逻辑源行的定义是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24363299/

相关文章:

c++ - 序列点从何而来?

编写十六进制和十进制数的简单加法的约定

c - 在结构中分配和访问指向字符串的指针

c - 指向整数并再次返回的指针

arrays - 将数组分配给 int 指针时出现警告 : initialization of 'int *' from ' int' makes pointer from integer without a cast,

具有可能指向 malloc 分配字段的结构字段的常量指针数组?

c++ - "=!"运算符是做什么的?

c - 如何将数据从缓冲区放入 C 中的数组?

在不使用 c99 标准的情况下使用 bool 编译 c 代码

c - 标准 C 中是否需要文字后缀?