mikroC - C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Within parentheses,
Unlike with variable declaration, each argument in the list needs its own type specifier and a possible qualifier const or volatile.
Function PrototypesA given function can be defined only once in a program, but can be declared several 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.
page |
|
96 | MikroElektronika: Development tools - Books - Compilers |
|