Home >Backend Development >C++ >What Determines the Evaluation Order of Function Parameters in C and C ?

What Determines the Evaluation Order of Function Parameters in C and C ?

Susan Sarandon
Susan SarandonOriginal
2024-12-21 06:35:10472browse

What Determines the Evaluation Order of Function Parameters in C and C  ?

Function Parameter Evaluation Order

In C and C , the order in which function parameters are evaluated is not specified by the language standards.

Evaluation Order

According to the C99 standard, the evaluation order of parameters is unspecified. However, there is a sequence point before the actual function call, meaning that all parameter evaluations are guaranteed to complete before the function is executed.

In C , the order of argument evaluation is also unspecified. Side effects of all argument expressions occur before the function is entered.

Function Call Implementation

The C and C standards do not require that function calls be implemented using the hardware stack. This is an implementation detail left to the compiler and platform. In practice, however, most popular architectures do use the hardware stack for parameter passing.

Conflicting Information

Confusion about parameter evaluation order can arise from incomplete or incorrect information in books. The language standards are the definitive source of information on this topic. The official C99 and C11 drafts, as well as the public C draft, are available online and provide clear guidance on this matter.

The above is the detailed content of What Determines the Evaluation Order of Function Parameters in C and C ?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn