Datasheet

FUNCTION CALLS AND ARGUMENT CONVERSIONS
Function Calls
A function is called with actual arguments placed in the same sequence as their
matching formal parameters. Use the function-call operator ():
function_name(expression_1, ... , expression_n)
Each expression in the function call is an actual argument. Number and types of
actual arguments should match those of formal function parameters. If types do not
match, implicit type conversions rules will be applied. Actual arguments can be of
any complexity, but order of their evaluation is not specified.
Upon function call, all formal parameters are created as local objects initialized by
the values of actual arguments. Upon return from a function, a temporary object is
created in the place of the call, and it is initialized by the expression of the return
statement. This means that the function call as an operand in complex expression
is treated as a function result.
If the function has no result (type
void) or the result is not needed, then the func-
tion call can be written as a self-contained expression.
In C, scalar arguments are always passed to the function by value. The function can
modify the values of its formal parameters, but this has no effect on the actual argu-
ments in the calling routine. A scalar object can be passed by the address if a for-
mal parameter is declared as a pointer. The pointed object can be accessed by
using the indirection operator
* .
// For example, Soft_Uart_Read takes the pointer to error variable,
// so it can change the value of an actual argument:
Soft_Uart_Read(&error);
// The following code would be wrong; you would pass the value
// of error variable to the function:
Soft_Uart_Read(error);
190
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5