开发者

warning: control reaches end of non-void function

I have a function named

void *func(void *arg)
{
    ///does some operation
}

Now I am getting a compiler开发者_开发问答 warning that "control reaches end of non-void function" even though i declare the return type as void *.

Can anyone please tell me how to fix up this warning?


The return type is void *, that means that you will return a pointer. Perhaps you wanted to type void, which means that you will not return anything?


We need all the code to truly see what is going on, but he compiler cannot tell from that code if the function will ever reach the end and still return something. You said it would return a pointer -- a void* -- and returned nothing. That isn't a void function, that is a void* function. The compiler is expecting you to return a void*, but instead you just fall off the end of the function.

You may also have an infinite while loop, which the compiler is smart enough to know that the function will not return, but this is pure speculation because you did not post all the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜