Specifications
CAVR-4
224
Descriptions of pragma directives
AVR® IAR C/C++ Compiler
Reference Guide
#pragma segment #pragma segment="segment" [memattr] [align]
The #pragma segment directive declares a segment name that can be used by the
intrinsic functions
__segment_begin and __segment_end. All segment declarations
for a specific segment must have the same memory type attribute and alignment.
The optional memory attribute
memattr will be used in the return type of the intrinsic
function. The optional parameter
align can be specified to align the segment part. The
value must be a constant integer expression to the power of two.
Example
#pragma segment="MYSEG" __huge 4
See also __segment_begin, page 241.
For more information about segments and segment parts, see the chapter Placing code
and data.
#pragma type_attribute #pragma type_attribute=keyword
The #pragma type_attribute directive can be used for specifying IAR-specific type
attributes, which are not part of the ISO/ANSI C language standard. Note however, that
a given type attribute may not be applicable to all kind of objects. For a list of all
supported type attributes, see Type and object attributes, page 144.
The #pragma type_attribute directive affects the declaration of the identifier, the
next variable, or the next function that follows immediately after the pragma directive.
Example
In the following example, even though IAR-specific type attributes are used, the
application can still be compiled by a different compiler. First, a typedef is declared;
a char object with the memory attribute __near is defined as MyCharInNear. Then a
pointer is declared; the pointer is located in far memory and it points to a
char object
that is located in near memory.
#pragma type_attribute=__near
typedef char MyCharInNear;
#pragma type_attribute=__far
MyCharInNear * ptr;
The following declarations, which use extended keywords, are equivalent. See the
chapterExtended keywords for more details.
char __near * __far ptr;