Atmel CAVR-4 Manual De Usuario
CAVR-4
142
Pointer types
AVR® IAR C/C++ Compiler
Reference Guide
CASTING
Casts between pointers have the following characteristics:
●
Casting a value of an integer type to a pointer of a smaller type is performed by
truncation
truncation
●
Casting a value of an integer type to a pointer of a larger type is performed by zero
extension
extension
●
Casting a pointer type to a smaller integer type is performed by truncation
●
Casting a pointer type to a larger integer type is performed via casting to the largest
possible pointer that fits in the integer
possible pointer that fits in the integer
●
Casting a data pointer to a function pointer and vice versa is illegal
●
Casting a function pointer to an integer type gives an undefined result.
size_t
size_t
is the unsigned integer type required to hold the maximum size of an object.
The following table shows the
typedef
of
size_t
depending on the processor option:
_ _farflash
3 bytes
Code
signed int
0x0–0xFFFFFF
(16-bit arithmetics)
_ _hugeflash
3 bytes
Code
signed long 0x0–0xFFFFFF
_ _eeprom
1 byte
EEPROM
signed char 0x0–0xFF
_ _eeprom
2 bytes
EEPROM
signed int
0x0–0xFFFF
_ _generic
2 bytes
3 bytes
Data/Code
signed int
signed long
The most significant bit (MSB)
determines whether __generic
points to CODE (1) or DATA (0). The
small generic pointer is generated
for the processor options -v0 and
-v1
.
Generic processor option
Typedef
-v0
and -v1
unsigned
int
-v2
, -v3, -v4, -v5, and -v6
unsigned
long
Table 35: size_t typedef
Keyword
Pointer size Memory space Index type
Range
Table 34: Data pointers