Technical Support

C166: RETURN(0) IN A VOID FUNCTION

QUESTION

I have C166 compiler v1.13. Why is it impossible to use return(0); in a function which is declared as:

void function_name (void)

ANSWER

The reason for the error/warning message is because a void function, by definition, does not return a value. When you include the return (0) statement, you are saying that the function returns a value of 0. This presents the compiler with a contradicting declaration and return. So, the compiler generates an error.

Use return; instead of return(0); to exit a void function.

Last Reviewed: Monday, June 07, 2004


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