Atmel CAVR-4 Manual De Usuario
CAVR-4
28
Function storage
AVR® IAR C/C++ Compiler
Reference Guide
Syntax
The extended keywords are specified before the return type, for example:
_ _interrupt void alpha(void);
The keywords that are type attributes must be specified both when they are defined and
in the declaration. Object attributes only have to be specified when they are defined
since they do not affect the way an object or function is used.
in the declaration. Object attributes only have to be specified when they are defined
since they do not affect the way an object or function is used.
In addition to the rules presented here—to place the keyword directly in the code—the
directives
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.
how to use the extended keywords together with pragma directives.
Function storage
There are two memory attributes for controlling function storage:
_ _nearfunc
and
_ _farfunc
.
The following table summarizes the characteristics for each memory attribute:
When using the
-v5
or the
-v6
option, it is possible, for individual functions, to override
the
_ _farfunc
attribute and instead use the
_ _nearfunc
attribute. The default
memory attribute can be overridden by explicitly specifying a memory attribute in the
function declaration or by using the
function declaration or by using the
#pragma type_attribute
directive:
#pragma type_attribute=_ _nearfunc
void MyFunc(int i)
{
...
}
It is possible to call a
_ _nearfunc
function from a
_ _farfunc
function and vice versa.
Only the size of the function pointer is affected. Note that pointers with function
memory attributes have restrictions in implicit and explicit casts when casting between
pointers and also when casting between pointers and integer types; see Casting, page
142. For more information about function pointers, see Function pointers, page 141.
memory attributes have restrictions in implicit and explicit casts when casting between
pointers and also when casting between pointers and integer types; see Casting, page
142. For more information about function pointers, see Function pointers, page 141.
It is possible to place functions into named segments using either the
@
operator or the
#pragma
location
directive. For more information, see Controlling data and function
Memory attribute
Address range
Pointer size
Used in processor option
_ _nearfunc
0-0x1FFFE
(128 Kbytes) 16 bits
-v0
, -v1, -v2, -v3, -v4
_ _farfunc
0-0x7FFFFE
(8 Mbytes)
24 bits
-v5
, -v6
Table 8: Memory attributes for functions