在下面的代码中:
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.
关于C 操作顺序——foo() + bar()——必须在 bar 之前调用 foo 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10358708/