Atmel CAVR-4 Manuale Utente

Pagina di 323
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
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; 
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;