User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
233
// 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);
Argument Conversions
If a function prototype has not been previously declared, the mikroC PRO for PIC32 converts integral arguments to
a function call according to the integral widening (expansion) rules described in Standard Conversions. If a function
prototype is in scope, the mikroC PRO for PIC32 converts the passed argument to the type of the declared parameter
according to the same conversion rules as in assignment statements.
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. The user can always use an explicit cast to convert an argument to a type that
is acceptable to a function prototype.
Note: If the function prototype does not match the actual function denition, the mikroC PRO for PIC32 will detect
this if and only if that denition is in the same compilation unit as the prototype.
If you create a library of routines with the corresponding header le of prototypes, consider including that
header le when you compile the library, so that any discrepancies between the prototypes and actual
denitions will be detected.
The compiler is also able to force arguments to change their type to a proper one. Consider the following code:
int limit = 32;
char ch = ‘A’;
long res;
// prototype
extern long func(long par1, long par2);
main() {
...
res = func(limit, ch); // function call
}
Since the program has the function prototype for func, it 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 be placed on the stack as an integer and a character, respectively;
in that case, the stack passed to func will not match size or content that func expects, which can cause problems.