调用一个函数没有参数,但它需要1 [K&安培; R-C] [英] Call a function without argument, although it needs one [K&R-C]
问题描述
这是K&放大器; RC和这里是code: http://v6shell.org/history/if.c
It's K&R-C and here is the code: http://v6shell.org/history/if.c
看主法。有这条线:如果(EXP())。
Look at the main-Method. There is this line "if(exp())".
但exp函数声明为:EXP(S)。因此,它需要一个说法。
But the function exp is declared as: exp(s). So it needs an argument.
为什么这项工作?你为什么要这么做?
推荐答案
归根结底,这是Unix V6壳保障指挥的错误,如果
。
Ultimately, it is a bug in the Unix V6 shell support command, if
.
在code的作用是:
exp(s) {
int p1;
p1 = e1();
if (eq(nxtarg(), "-o")) return(p1 | exp());
ap--;
return(p1);
}
功能参数取值
,隐式类型的 INT
(因为是功能iteself),在实际未使用的功能,所以错误是取值
,没有缺席,在调用的参数来 EXP()$的presence C $ C>。所有零实际参数的调用是正确的。
The function parameter s
, implicitly of type int
(as is the function iteself), is actually unused in the function, so the bug is the presence of s
, not the absence of an argument in the calls to exp()
. All the calls with zero actual arguments are correct.
这篇关于调用一个函数没有参数,但它需要1 [K&安培; R-C]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!