Atmel CAVR-4 ユーザーズマニュアル
CAVR-4
Part 1. Using the compiler
Data storage
21
Differences between pointer types
A pointer must contain information needed to specify a memory location of a certain
memory type. This means that the pointer sizes are different for different memory types.
For information about the sizes of the different pointer types, seePointer types, page 141.
memory type. This means that the pointer sizes are different for different memory types.
For information about the sizes of the different pointer types, seePointer types, page 141.
In the AVR IAR C/C++ Compiler, it is illegal to convert pointers between different types
without using explicit casts. For more details, see Casting, page 142.
without using explicit casts. For more details, see Casting, page 142.
STRUCTURES AND MEMORY TYPES
For structures, the entire object is placed in the same memory type. It is not possible to
place individual structure members in different memory types.
place individual structure members in different memory types.
In the example below, the variable
gamma
is a structure placed in eeprom memory.
struct MyStruct
{
int alpha;
int _ _flash * beta; /* Pointer to variables in flash memory */
};
_ _eeprom struct MyStruct gamma;
The following declaration is incorrect:
struct MySecondStruct
{
int blue;
_ _eeprom int green; /* Error! */
};
MORE EXAMPLES
The following is a series of examples with descriptions. First, some integer variables are
defined and then pointer variables are introduced. Finally, a function accepting a pointer
to an integer in flash memory is declared. The function returns a pointer to an integer in
eeprom memory. It makes no difference whether the memory attribute is placed before
or after the data type. In order to read the following examples, start from the left and add
one qualifier at each step
defined and then pointer variables are introduced. Finally, a function accepting a pointer
to an integer in flash memory is declared. The function returns a pointer to an integer in
eeprom memory. It makes no difference whether the memory attribute is placed before
or after the data type. In order to read the following examples, start from the left and add
one qualifier at each step
int a;
A variable defined in default memory.
int _ _flash b;
A variable in flash memory.
_ _eeprom int c;
A variable in eeprom memory.
int * d;
A pointer stored in default memory. The pointer
points to an integer in default memory.
points to an integer in default memory.