Specifications
CAVR-4
22
C++ and memory types
AVR® IAR C/C++ Compiler
Reference Guide
In short:
C++ and memory types
A C++ class object is placed in one memory type, in the same way as for normal C
structures. However, the class members that are considered to be part of the object are
the non-static member variables. The static member variables can be placed individually
in any kind of memory.
Remember, in C++ there is only one instance of each static member variable, regardless
of the number of class objects.
Also note that for non-static member functions—unless class memory is used, see
Classes, page 111—the
this pointer will be of the default data pointer type. This means
that it must be possible to convert a pointer to the object to the default pointer type. The
restrictions that apply to the default pointer type also apply to the
this pointer.
int __flash * e;
A pointer stored in default memory. The pointer
points to an integer in flash memory.
int __flash * __eeprom f;
A pointer stored in eeprom memory pointing to
an integer stored in flash memory.
int __eeprom * myFunction(
int __flash *);
A declaration of a function that takes a
parameter which is a pointer to an integer stored
in flash memory. The function returns a pointer
to an integer stored in eeprom memory.
int
The basic type is an integer.
int __flash
The integer is stored in flash memory.
int __flash *
This is a pointer to the integer.
int __flash * __eeprom
The pointer is stored in eeprom memory.