ABL electronic PIC16 Personal Computer User Manual


 
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 function calls for validity. If the list is
empty, function does not take any arguments. Also, if the list is
void, 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 with variable declaration, each argument in the list needs its own type
specifier and a possible qualifier
const or volatile.
Function Prototypes
A given function can be defined only once in a program, but can be declared sev-
eral times, provided the declarations are compatible. If you write a nondefining
declaration of a function, i.e. without the function body, you do not have to specify
the formal arguments. This kind of declaration, commonly known as the function
prototype, allows better control over argument number and type checking, and
type conversions.
Name of the parameter in function prototype has its scope limited to the prototype.
This allows different parameter names in different declarations of the same func-
tion:
/* 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 greatly aid 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, you can that file to get
the information you need for writing programs that call those functions. If you
include an identifier in a prototype parameter, it is used only for any later error
messages involving that parameter; it has no other effect.
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
96
MikroElektronika:
Development
tools
-
Books
-
Compilers
page