Datasheet
FUNCTIONS
Functions are central to C programming. Functions are usually defined as subpro-
grams which return a value based on a number of input parameters. Return value
of the function can be used in expressions – technically, function call is considered
to be an expression like any other.
C allows a function to create results other than its return value, referred to as side
effects. Often, the 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
user-supplied header files, or within program files. Functions have external linkage
by default and are normally accessible from any file in the program. This can be
restricted by using the static storage class specifier in function declaration (see
Storage Classes and Linkage).
Note: Check the AVR Specifics for more information on functions’ limitations on the
AVR compliant micros.
Function Declaration
Functions are declared in user's source files or made available by linking precom-
piled libraries. The declaration syntax of the function is:
type function_name(parameter-declarator-list);
The function_name must be a valid identifier. This name is used to call the func-
tion; see Function Calls for more information.
type represents the type of function result, and can be of any standard or user-
defined type. For functions that do not return value the
void type should be used.
The type can be omitted in global function declarations, and function will assume the
int type by default.
Function type can also be a pointer. For example, float* means that a function
result is a pointer to float. The generic pointer void* is also allowed.
The function cannot return an array or another function.
187
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5