ARM Technical Support Knowledge Articles

RETURN(0) IN A VOID FUNCTION

Applies to: C166 C Compiler

Answer

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.

Article last edited on: 2004-06-07 09:46:32

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential