Parameter Evaluation Order in C and C
The evaluation order of function parameters in C and C is an important consideration for developers. Both C99 and C11 standards specify that the order of evaluation is not explicitly defined. This means that the compiler is free to determine the evaluation order.
However, it's important to note that all side effects of argument expression evaluations must take effect before the function is called in C . In other words, any modifications to variables or other state must occur before the function body is executed.
The C standard also states that the evaluation order of the postfix expression and the argument expression list is unspecified. This means that the compiler can determine the order in which these expressions are evaluated.
In contrast, the C11 standard specifies that there is a sequence point after the evaluations of the function designator and actual arguments but before the actual call. This means that the evaluation of the actual arguments is separated from the execution of the called function body.
Regarding the implementation of function calls, neither the C nor C standards specify that they must use the hardware stack. This is an implementation detail that is left to the compiler writer. While many architectures do pass parameters via a hardware stack, this is not universally true.
The above is the detailed content of What is the Parameter Evaluation Order in C and C ?. For more information, please follow other related articles on the PHP Chinese website!