Specifications

CAVR-4
16
Introduction
AVR® IAR C/C++ Compiler
Reference Guide
On the heap. Once memory has been allocated on the heap, it remains valid until it
is explicitly released back to the system by the application. This type of memory is
useful when the number of objects is not known until the application executes. Note
that there are potential risks connected with using the heap in systems with a limited
amount of memory, or systems that are expected to run for a long time.
EXTENDED KEYWORDS FOR DATA
The extended keywords that can be used for data control the following:
For data memory space, keywords that control the placement and type of objects
and pointers: __tiny, __near, __far, __huge, and __regvar
For the EEPROM memory space, keyword that controls the placement and type of
objects and pointers:
__eeprom
For the code (flash) memory space, keywords that control the placement and type of
objects and pointers: __tinyflash, __flash, __farflash, and __hugeflash
For the I/O memory space, keyword that controls the placement and type of objects
and pointers: __ext_io, __io
Special pointer that can access data objects in both data and code memory space:
__generic
Other characteristics of objects: __root and __no_init.
See the chapter Data storage in Part 1. Using the compiler for more information about
how to use data memory types.
Syntax
The keywords follow the same syntax as the type qualifiers const and volatile. The
following declarations place the variable
i and j in EEPROM memory. The variables k
and l behave in the same way:
__eeprom int i, j;
int __eeprom k, l;
Note that the keyword affects both identifiers.
In addition to the rules presented here—to place the keyword directly in the code—the
directives
#pragma type_attribute and #pragma object_attribute can be used
for specifying the keywords. Refer to the chapter Pragma directives for details about
how to use the extended keywords together with pragma directives.
Pointers
A keyword that is followed by an asterisk (*), affects the type of the pointer being
declared. A pointer to EEPROM memory is thus declared by:
char __eeprom * p;