C操作顺序 – foo()bar() – 必须在bar之前调用foo?

在以下代码中:

int foo();
int bar();
int i;

i = foo() + bar();

是否通过C标准保证在调用bar之前调用foo?

最佳答案
不,没有序列点.维基百科页面上有一个关于它的引用可以回答你的问题:

Consider two functions f() and g(). In C and C++, the + operator is not associated with a sequence point, and therefore in the expression f()+g() it is possible that either f() or g() will be executed first.

http://en.wikipedia.org/wiki/Sequence_points

转载注明原文:C操作顺序 – foo()bar() – 必须在bar之前调用foo? - 代码日志