Atmel CAVR-4 사용자 설명서
CAVR-4
Part 2. Compiler reference
Data representation
143
ptrdiff_t
ptrdiff_t
is the type of the signed integer required to hold the difference between two
pointers to elements of the same array. The following table shows the
typedef
of
ptrdiff_t
depending on the processor option:
Note: Subtracting the start address of an object from the end address can yield a
negative value, because the object can be larger than what the
negative value, because the object can be larger than what the
ptrdiff_t
can represent.
See this example:
char buff[60000]; /* Assuming ptrdiff_t is a 16-bit */
char *p1 = buff; /* signed integer type. */
char *p2 = buff + 60000;
ptrdiff_t diff = p2 - p1;
intptr_t
intptr_t
is a signed integer type large enough to contain a
void
*
. In the AVR IAR
C/C++ Compiler, the size of
intptr_t
is
long int
when using the Large memory
model and
int
in all other cases.
uintptr_t
uintptr_t
is equivalent to
intptr_t
, with the exception that it is unsigned.
Structure types
The members of a
struct
are stored sequentially in the order in which they are
declared: the first member has the lowest memory address.
ALIGNMENT
The
struct
and
union
types inherit the alignment requirements of their members. In
addition, the size of a
struct
is adjusted to allow arrays of aligned structure objects.
GENERAL LAYOUT
Members of a
struct
(fields) are always allocated in the order given in the declaration.
The members are placed in memory according to the given alignment (offsets), which
always is 1.
always is 1.
Generic processor option
Typedef
-v0
and -v1
signed
int
-v2
, -v3, -v4, -v5, and -v6
signed
long
Table 36: ptrdiff_t typedef