Xcode IDE Showing Error: "Control Reaches End Of Non-Void Function"
Solution 1:
The warning message is very clear, you're not returning a value, as promised.
The add()
function returns an int
, but in your code, there is no return
statement altogether. You need to return a value, as the return type you define is int
.
Quoting C11
, chapter 6.9.1/P12
If the
}
that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.
So your compiler is trying to warn you of possible pitfall.
That said
- You need to forward declare your function outside
main()
. -
You should call the
add()
function frommain()
, something likeint main() { add(); }