mikroC
making it simple...
FUNCTIONS
mikroC - C Compiler for Microchip PIC microcontrollers
Functions are central to C programming. Functions are usually defined as subprograms which return a value based on a number of input parameters. Return value of a function can be used in expressions – technically, function call is considered an operator like any other.
C allows a function to create results other than its return value, referred to as side effects. Often, function return value is not used at all, depending on the side effects. These functions are equivalent to procedures of other programming lan- guages, such as Pascal. C does not distinguish between procedure and function – functions play both roles.
Each program must have a single external function named main marking the entry point of the program. Functions are usually declared as prototypes in standard or
Note: Check the PIC Specifics for more info on functions’ limitations on PIC micros.
Function Declaration
Functions are declared in your source files or made available by linking precompiled libraries. Declaration syntax of a function is:
type
The function_name must be a valid identifier. This name is used to call the function; see Function Calls for more information. The type represents the type of function result, and can be any standard or
Function type can also be a pointer. For example, float* means that the function result is a pointer to float. Generic pointer, void* is also allowed. Function cannot return array or another function.
|
| page |
MikroElektronika: Development tools - Books - Compilers | 95 | |
|