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

标签 c

在下面的代码中:

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 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10358708/

相关文章:

c - scanf在c中获取整数和字符

c - 尝试写入文件时 fprintf 不起作用

c++ - 文件记录的有效方法

c - 有没有办法用 2 个信号量来解决生产者-消费者问题?

python - 如何从 C 语言访问 python 字典?

c - POSIX:从 UDP 套接字上的 write() 返回值

c - 为什么 malloc 分配已经分配的内存位置?

c - 代码段的动态重定位

c - 使用 C 程序验证用私钥签名的摘要

c - 关于整数格式转换