大佬教程收集整理的这篇文章主要介绍了c – 对于三元操作,“警告:操作……可能未定义” – 如果/ else阻止,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
int main() { static int test = 0; const int anotherInt = 1; test = anotherInt > test ? test++ : 0; if (anotherInt > test) test++; else test = 0; return 0; }
这是我构建它时产生的警告:
../main.cpp:15:40: warning: operation on ‘test’ may be undefined [-Wsequence-point] test= anotherInt>test ? test++ : 0; ^
为什么C会对三元操作发出警告,而不是常规if..else语句?
将if条件更改为:
if(anotherInt > test) test = test++; // undefined!
您可能也会在此处看到相同的警告.
以上是大佬教程为你收集整理的c – 对于三元操作,“警告:操作……可能未定义” – 如果/ else阻止全部内容,希望文章能够帮你解决c – 对于三元操作,“警告:操作……可能未定义” – 如果/ else阻止所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。