UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
2,724 Views
Registered: ‎10-25-2012

What does this warning "control reaches end of non-void function [-Wreturn-type]" mean?

Jump to solution

I got this warning in my code:

 

control reaches end of non-void function [-Wreturn-type]  

 

 

What does this mean?

 

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Explorer
Explorer
3,509 Views
Registered: ‎05-12-2011

Re: What does this warning "control reaches end of non-void function [-Wreturn-type]" mean?

Jump to solution

It means you have a function that's supposed to return some type of value, and there is a way for the processor to "fall off" the end of the function without executing a return statement.  Therefore the code that calls this function is expecting a return value, but it's possible the function will not return one and that's why you get the warning.  If that's how you intended the function to work because you guaranteed by design that not returning a value will not cause a problem, you can turn off that warning.  The warning in question is -Wreturn-type, so to specifically disable that warning you would add -Wno-return-type to the build settings for the Makefile.  However I would suggest you at least return zero instead of just turning off the warning.  Otherwise you may miss the fact that you forgot to put a return statement at the end of one of your functions.

 

Cheers,

-Doug

View solution in original post

0 Kudos
2 Replies
Highlighted
Explorer
Explorer
3,510 Views
Registered: ‎05-12-2011

Re: What does this warning "control reaches end of non-void function [-Wreturn-type]" mean?

Jump to solution

It means you have a function that's supposed to return some type of value, and there is a way for the processor to "fall off" the end of the function without executing a return statement.  Therefore the code that calls this function is expecting a return value, but it's possible the function will not return one and that's why you get the warning.  If that's how you intended the function to work because you guaranteed by design that not returning a value will not cause a problem, you can turn off that warning.  The warning in question is -Wreturn-type, so to specifically disable that warning you would add -Wno-return-type to the build settings for the Makefile.  However I would suggest you at least return zero instead of just turning off the warning.  Otherwise you may miss the fact that you forgot to put a return statement at the end of one of your functions.

 

Cheers,

-Doug

View solution in original post

0 Kudos
Explorer
Explorer
2,706 Views
Registered: ‎10-25-2012

Re: What does this warning "control reaches end of non-void function [-Wreturn-type]" mean?

Jump to solution
Thanks, miss a return is the problem. I have fixed the codes.
0 Kudos