本文介绍了功能参数的评估顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 考虑这个功能, void fun(int i,int j) { printf(" i =%d:j =%d",i,j); } 我称之为: fun(n ++,n); 这在用gcc 4.0编译时给出了以下输出: i = 9:j = 10 但是在gcc 3.4.3上输出的是: i = 9:j = 9 虽然订单对函数参数的评估是未指定的 编译器在不同的版本中是否仍然不一致? 可以解释为什么他们在版本4中更改了gcc? Rgrds, haroonConsider this function,void fun (int i, int j){printf ("i = %d : j = %d", i, j);}I call it like this:fun (n++, n);this when compiled with gcc 4.0 gives following out put:i = 9 : j = 10but on gcc 3.4.3 the out put is:i = 9 : j = 9although the order of evaluation for function arguments is unspecifiedstill shouldn''t the compiler be consistent in its different versions?can any one explain why did they change this in version 4 of gcc?Rgrds,haroon推荐答案 您的代码调用未定义的行为,因此编译器可以随意执行 。为什么不同版本之间应该保持一致,甚至在相同版本的不同编辑中使用?Your code invokes undefined behaviour, so the compiler is allowed to doas it pleases. Why should it be consistent across versions, or evenacross different compilations with the same version? < http://www.eskimo.com/~scs/C-faq/q3.2。 html> ;. HTH; HAND。 Richard<http://www.eskimo.com/~scs/C-faq/q3.2.html>.HTH; HAND.Richard 这篇关于功能参数的评估顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!