【发布时间】:2012-04-25 13:05:22
【问题描述】:
我不太明白 C99 中的语法是什么意思。这里所说的 C99 是指 ISO/IEC 9899:1999。好吧,我认为语法部分自 ANSI C、C89 以来并没有太大变化。
以this question为例:
6.5.5 Multiplicative operators
Syntax
multiplicative-expression:
cast-expression
multiplicative-expression * cast-expression
multiplicative-expression / cast-expression
multiplicative-expression % cast-expression
Constraints
Each of the operands shall have arithmetic type. The operands of the % operator
shall have integer type.
Semantics
The usual arithmetic conversions are performed on the operands.
The result of the binary * operator is the product of the operands.
The result of the / operator is the quotient
我想知道为什么在乘法运算符的语法中我们有一个“cast-expression”?这个语法可以暗示什么语法?在that question@Avi 说在
a*b*c
“c 必须被解析为强制转换表达式”,我不太明白。
再举一个c99 6.6.1的例子,常量表达式的语法
Syntax
constant-expression:
conditional-expression
为什么这个条件表达式会出现在这里? 有人可以告诉我如何解释这些语法吗?谢谢大家。
【问题讨论】: