c - 用于分组的圆括号是否被视为运算符?

标签 c operators language-lawyer

在 C 中,圆括号用于进行更多操作,例如函数调用和类型转换。

然而它们也被用来组合许多子表达式来改变 运算符的顺序评估。

我的疑问是:当用作分组运算符时,它们是否被视为运算符?

很多人说是,很多人说不是...

最佳答案

6.5 表达式章节 (N1570) 第 3 段

The grouping of operators and operands is indicated by the syntax. 85)

有以下注释:

85) The syntax specifies the precedence of operators in the evaluation of an expression, which is the same as the order of the major subclauses of this subclause, highest precedence first. Thus, for example, the expressions allowed as the operands of the binary + operator (6.5.6) are those expressions defined in 6.5.1 through 6.5.6. The exceptions are cast expressions (6.5.4) as operands of unary operators (6.5.3), and an operand contained between any of the following pairs of operators: grouping parentheses () (6.5.1), subscripting brackets [] (6.5.2.1), function-call parentheses () (6.5.2.2), and the conditional operator ?: (6.5.15).

所以 C 标准似乎将它们视为运算符。

关于c - 用于分组的圆括号是否被视为运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24238686/

相关文章:

C语言真的可以重新定义关键字吗?

c - 在函数中返回 char*

c - 对于非 GNU 链接器,是否有等效于 GNU 链接器 "--just-symbols"选项的选项?

R:+=(加等于)和++(加加)等价于c++/c#/java等?

c++ - 没有临时数组的列表初始化 - 在 GCC 中不起作用

tcl - 获取未评估的 tcl 参数

C 多重定义/首先在这里定义错误

java - 从纪元开始以秒为单位查找日期,模数不起作用

batch-file - 批处理 : what is the pipe | used for?

c++ - 将临时值存储为某种数据类型时,算术运算的标准规则是什么?