I have some code I have written to test whether a blank line has been reached in the music file but I am not familiar with how to return a Boolean statement as true in C. When I run make I am getting an error that says helpers.c:22:1: error: control reaches end of non-void function [-Werror,-Wreturn-type] and it shows one of the brackets. Here is the codes,

bool is_rest(string s)
    string blank = "";
    int value = strncmp(s, blank, 1);
    if (value == 0)
        return 1;

1 Answer 1


You get this error because it is possible to get to the end of the function without giving a value to return. Specifically, there's only the one return statement in the code. If value is not 0, then what is the program supposed to return?

If you simply add a return false; statement at the end, problem solved.

Side note: Best practice for a function that returns a bool is to return true or false, not a number. It's too easy to get confused. With true or false, there is no doubt what is being returned.

You might learn more from these links:



If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thanks for the help! Commented Oct 31, 2018 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .