c - 复合文字不是文字吗?

标签 c

简而言之,来自 C:

Chapter 3 Literals

In C source code, a literal is a token that denotes a fixed value, which may be an integer, a floating-point number, a character, or a string. A literal’s type is determined by its value and its notation.

The literals discussed here are different from compound literals, which were introduced in the C99 standard. Compound literals are ordinary modifiable objects, similar to variables. For a full description of compound literals and the special operator used to create them, see Chapter 5.

因此字面量具有固定值,即它的值不能被修改,而复合字面量具有可修改的值。

据此,哪一个是正确的:

  • 复合文字不是文字,或者
  • 字面量的定义应该扩展到包含复合字面量,它成为固定值规则的唯一异常(exception)?

谢谢。

最佳答案

C11 标准从不单独定义“文字”。它只单独谈到“字符串文字”和“复合文字”。

00.0enum { A } 中的 A '\0'统称为“常量”,分别称为“整数常量”、“ float 常量”、“枚举常量”、“字符常量”。

关于c - 复合文字不是文字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45684377/

相关文章:

c - 给出虚假值(value)的宏观方程?

c - 如何根据传递的结构名称部分访问结构

c - 指针和结构

iphone - Objective-c 调用 C 函数

c - 将行一行一行获取到动态分配的 char 数组

C (s)printf 漏洞利用,$hn 和 %10

c - "Address 0x7f out of bounds"通过函数传递参数

c - 为什么 GNU Readline 这么慢?

c - signed 和 unsigned int 之间的转换是否在内存中保持变量的精确位模式?

c - 是否可以使用 setitimer 配置 3 个以上的计时器?