Technical Support

C51: IS RETURN REQUIRED FOR VOID FUNCTIONS?

QUESTION

The ISO standard says that the last closing curly brace '}' is an implicit return statment. Thus in a function:

void func(void)
{
}

a return would not be needed.

Does the C51 compiler require the parameterless return statement? If not, is it a good idea to put it in?

ANSWER

C51 does not require a return statement for void functions. The best example of this is the main C function.

Nonetheless, it is a good idea to insert a return statement anyway. This way, you can look at the return statement and see that it doesn't return anything.

Last Reviewed: Thursday, May 20, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure