Datasheet
TYPES CONVERSIONS
The mikroC PRO for AVR is a strictly typed language, with each operator, statement
and function demanding appropriately typed operands/arguments. However, we
often have to use objects of “mismatching” types in expressions. In that case, type
conversion is needed.
Conversion of object of one type means that object's type is changed into another
type. The mikroC PRO for AVR defines a set of standard conversions for built-in
types, provided by compiler when necessary. For more information, refer to the
Standard Conversions.
Conversion is required in the following situations:
- if a statement requires an expression of particular type (according to lan
guage definition), and we use an expression of different type,
- if an operator requires an operand of particular type, and we use an
operand of different type,
- if a function requires a formal parameter of particular type, and we pass it
an object of different type,
- if an expression following the keyword
return does not match the
declared function return type,
- if intializing an object (in declaration) with an object of different type.
In these situations, compiler will provide an automatic implicit conversion of types,
without any programmer's interference. Also, the programmer can demand conver-
sion explicitly by means of the typecast operator. For more information, refer to the
Explicit Typecasting.
174
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5