[英]warning: control reaches end of non-void function in recursive function
I am getting warning: control reaches end of non-void function. 我收到警告:控制到达非空函数的末尾。
I have a recursive function that looks like this: 我有一个看起来像这样的递归函数:
unsigned long FUNCTION (....) {
if (something) {
return 1;
}
else if (something2) {
if(thing) {
FUNCTION(....);
}
else
return 0;
}
else {
return 0;
}
}
I can't just put return 0; 我不能只把return 0放进去。 at the end of the function because it ends up making my program do what I don't want it to.
在函数的末尾,因为它最终使我的程序执行我不希望做的事情。 How do I make the warning go away?
如何使警告消失?
The branch calling FUNCTION(...)
doesn't return anything. 调用
FUNCTION(...)
的分支不会返回任何内容。 As a result, if this branch is taken your function has undefined behavior. 结果,如果采用此分支,则您的函数具有未定义的行为。 What needs to be returned can't be determined from your code: you'll have to come up with that.
不能从代码中确定需要返回的内容:您必须提出相应的建议。
Note that FUNCTION
normally indicates that the name is a macro: there are a few conventions how things are named to avoid confusion. 请注意,
FUNCTION
通常表示名称是一个宏:为避免混淆,有一些约定如何命名事物。 You can call your functions with all uppercase letters but it may not be a good idea. 您可以使用所有大写字母调用函数,但这可能不是一个好主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.