|
| mikroC | |
mikroC - C Compiler for Microchip PIC microcontrollers | making it simple... | ||
|
|
|
|
Referring to declarations from the previous example:
page
80
mu.d = 4.016; |
|
|
|
Lcd_Out_Cp(FloatToStr(mu.d)); | // OK: displays | mu.d = 4.016 | |
Lcd_Out_Cp(IntToStr(mu.i)); | // | peculiar result | |
|
|
| |
Lcd_Out_Cp(IntToStr(mu.i)); | // | OK: displays | mu.i = 3 |
The second Lcd_Out_Cp is legal, since mu.i is an integral type. However, the bit pattern in mu.i corresponds to parts of the previously assigned double. As such, it probably does not provide a useful integer interpretation.
When properly converted, a pointer to a union points to each of its members, and vice versa.
Bit FieldsBit fields are specified numbers of bits that may or may not have an associated identifier. Bit fields offer a way of subdividing structures into named parts of user- defined sizes.
mikroC implementation of bit fields requires you to set aside a structure for the purpose, i.e. you cannot have a structure containing bit fields and other objects. Bit fields structure can contain up to 8 bits.
You cannot take the address of a bit field.
Note: If you need to handle specific bits of
Bit Fields Declaration
Bit fields can be declared only in structures. Declare a structure normally, and assign individual fields like this (fields need to be unsigned):
struct tag { unsigned
MikroElektronika: Development tools - Books - Compilers