Datasheet

Within parentheses, parameter-declarator-list is a list of formal arguments that
function takes. These declarators specify the type of each function parameter. The
compiler uses this information to check validity of function calls. If the list is empty,
a function does not take any arguments. Also, if the list is void, a function also does
not take any arguments; note that this is the only case when void can be used as
an argument’s type.
Unlike variable declaration, each argument in the list needs its own type specifier
and possible qualifier
const or volatile.
Function Prototypes
A function can be defined only once in the program, but can be declared several
times, assuming that the declarations are compatible. When declaring a function,
the formal argument's identifier does not have to be specified, but its type does.
This kind of declaration, commonly known as the function prototype, allows better
control over argument number, type checking and type conversions. The name of a
parameter in function prototype has its scope limited to the prototype. This allows
one parameter identifier to have different name in different declarations of the same
function:
/* Here are two prototypes of the same function: */
int test(const char*) /* declares function test */
int test(const char*p) /* declares the same function test */
Function prototypes are very useful in documenting code. For example, the function
Cf_Init takes two parameters: Control Port and Data Port. The question is, which
is which? The function prototype:
void Cf_Init(char *ctrlport, char *dataport);
makes it clear. If a header file contains function prototypes, the user can read that
file to get the information needed for writing programs that call these functions. If a
prototype parameter includes an identifier, then the indentifier is only used for error
checking.
FUNCTION DEFINITION
Function definition consists of its declaration and function body. The function body
is technically a block – a sequence of local definitions and statements enclosed
within braces {}. All variables declared within function body are local to the func-
tion, i.e. they have function scope.
188
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5