Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对 avr-gcc 有一个奇怪的问题。如果我这样做:
int i = 0; i = ++i;
它会导致编译器警告:
warning: operation on ‘i’ may be undefined
这里有什么问题?
如果重写为
i = i + 1;
它不会导致警告。
avr-gcc 是 4.3.4 版本,我在 Ubuntu 10.04 上运行它。
如果您打算简单地增加i,那么使用
i
或者
++i;
(或i++),但不能两者兼而有之。C 的规则不允许您在单个序列点之前修改变量两次。preincrement ( ++i) 和 assignment ( i =) 都修改了 的值i。
i++
++i
i =