Atmel CAVR-4 ユーザーズマニュアル
CAVR-4
144
Type and object attributes
AVR® IAR C/C++ Compiler
Reference Guide
Example
struct {
short s;
/* stored in byte 0 and 1 */
char c;
/* stored in byte 2 */
long l;
/* stored in byte 4, 5, and 6 */
char c2; /* stored in byte 7 */
} s;
The following diagram shows the layout in memory:
The alignment of the structure is 1 byte, and its size is 8 bytes.
Type and object attributes
The AVR IAR C/C++ Compiler provides a set of attributes that support specific features
of the AVR microcontroller. There are two basic types of attributes—type attributes and
object attributes.
of the AVR microcontroller. There are two basic types of attributes—type attributes and
object attributes.
Type attributes affect the external functionality of the data object or function. For
instance, how an object is placed in memory, or in other words, how it is accessed.
instance, how an object is placed in memory, or in other words, how it is accessed.
Object attributes affect the internal functionality of the data object or function.
To understand the syntax rules for the different attributes, it is important to be familiar
with the concepts of the type attributes and the object attributes.
with the concepts of the type attributes and the object attributes.
For information about how to use attributes to modify data, see the chapter Data storage.
For information about how to use attributes to modify functions, see the chapter
Functions. For detailed information about each attribute, see Descriptions of extended
keywords, page 204.
For information about how to use attributes to modify functions, see the chapter
Functions. For detailed information about each attribute, see Descriptions of extended
keywords, page 204.
TYPE ATTRIBUTES
Type attributes define how a function is called, or how a data object is accessed. This
means that type attributes must be specified both when they are defined and in the
declaration.
means that type attributes must be specified both when they are defined and in the
declaration.
You can either place the type attributes directly in your source code, or use the pragma
directive
directive
#pragma
type_attribute
.
s.s
2 bytes
s.c
1 byte
s.l
4 bytes
s.c2
1 byte