ABL electronic PIC16 Personal Computer User Manual


 
If a prototype is present, the number of arguments must match. The types need to
be compatible only to the extent that an assignment can legally convert them. You
can always use an explicit cast to convert an argument to a type that is acceptable
to a function prototype.
Note: If your function prototype does not match the actual function definition,
mikroC will detect this if and only if that definition is in the same compilation unit
as the prototype. If you create a library of routines with a corresponding header
file of prototypes, consider including that header file when you compile the
library, so that any discrepancies between the prototypes and the actual definitions
will be caught.
The compiler is also able to force arguments to the proper type. Suppose you have
the following code:
int limit = 32;
char ch = 'A';
long res;
extern long func(long par1, long par2);
// prototype
main() {
//...
res = func(limit, ch);
// function call
}
Since it has the function prototype for func, this program converts limit and ch
to long, using the standard rules of assignment, before it places them on the stack
for the call to func.
Without the function prototype,
limit and ch would have been placed on the
stack as an integer and a character, respectively; in that case, the stack passed to
func would not match in size or content what func was expecting, leading to
problems.
MikroElektronika:
Development
tools
-
Books
-
Compilers
99
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...