Keil Logo

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 7, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.