ARM Technical Support Knowledge Articles

IS RETURN REQUIRED FOR VOID FUNCTIONS?

Applies to: C51 C Compiler

Answer

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.

Article last edited on: 2004-05-20 20:44:37

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