In its own definition, a postfix operator is an operator specified after all of its operands.
In C11 Standard, a postfix operator is defined as:
6.5.2 Postfix operators
Syntax
postfix-expression: primary-expression postfix-expression [ expression ] postfix-expression ( argument-expression-listopt ) postfix-expression . identifier postfix-expression -> identifier postfix-expression ++ postfix-expression -- ( type-name ) { initializer-list } ( type-name ) { initializer-list , }
The standard calls the two parts before and after
.
and->
as operands, which I highlighted in bold in the following quote. Does it mean.
and->
are actually infix operators, in spite of being called postfix operators in the standard?6.5.2.3 Structure and union members
Constraints
1 The first operand of the . operator shall have an atomic, qualified, or unqualified structure or union type, and the second operand shall name a member of that type.
2 The first operand of the -> operator shall have type ‘‘pointer to atomic, qualified, or unqualified structure’’ or ‘‘pointer to atomic, qualified, or unqualified union’’, and the second operand shall name a member of the type pointed to.
The subsections for
[]
,()
and compound literals don't mention the word "operands". So- are
[]
and()
both unary postfix operators, with a (function) pointer name before them as their only operand, and what inside[]
and()
are not operands? This is what the accpeted reply says In a function call, what is the operator, and what are the operands? - What is the operator of compound literals,
()
,(type-name)
or something else?initializer-list
within{}
might be not operand(s), just like the array index in[]
and function arguments in()
.{}
might be not part of the operator, because it is used for enclosing the initializers. If the operator of compound literals is(type-name)
, does the compound literal operator not take any operand?
- are
Although cast operators are not postfix operators in C, it looks confusingly almost the same as compound literal operators.
6.5.4 Cast operators Syntax
cast-expression: unary-expression ( type-name ) cast-expression
Constraints 2 Unless the type name specifies a void type, the type name shall specify atomic, qualified, or unqualified scalar type, and the operand shall have scalar type.
So is a cast operator
()
or(type-name)
? Is its operandcast-expression
, or bothtype-name
andcast-expression
?
Thanks.