|
Home / Compiler User Guide
Basic data types in ARM C and C++
10.2 Basic data types in ARM C and C++
Describes the basic data types implemented in ARM C and C++:
Size and alignment of basic data types
The following table gives the size
and natural alignment of the basic data types.
Table 10-2 Size and alignment of data types
Type |
Size in bits |
Natural alignment in bytes |
Range of values |
char |
8 |
1 (byte-aligned) |
0 to 255 (unsigned) by default.
–128 to 127 (signed) when compiled with --signed_chars .
|
signed char |
8 |
1 (byte-aligned) |
–128 to 127
|
unsigned char |
8 |
1 (byte-aligned) |
0 to 255
|
(signed) short |
16 |
2 (halfword-aligned) |
–32,768 to 32,767 |
unsigned short |
16 |
2 (halfword-aligned) |
0 to 65,535 |
(signed) int |
32 |
4 (word-aligned) |
–2,147,483,648 to 2,147,483,647 |
unsigned int |
32 |
4 (word-aligned) |
0 to 4,294,967,295 |
(signed) long |
32 |
4 (word-aligned) |
–2,147,483,648 to 2,147,483,647 |
unsigned long |
32 |
4 (word-aligned) |
0 to 4,294,967,295 |
(signed) long long |
64 |
8 (doubleword-aligned) |
–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
unsigned long long |
64 |
8 (doubleword-aligned) |
0 to 18,446,744,073,709,551,615 |
float |
32 |
4 (word-aligned) |
1.175494351e-38 to 3.40282347e+38 (normalized values) |
double |
64 |
8 (doubleword-aligned) |
2.22507385850720138e-308 to 1.79769313486231571e+308 (normalized values) |
long double |
64 |
8 (doubleword-aligned) |
2.22507385850720138e-308 to 1.79769313486231571e+308 (normalized values) |
wchar_t |
16
32
|
2 (halfword-aligned)
4 (word-aligned)
|
0 to 65,535 by default.
0 to 4,294,967,295 when compiled with --wchar32 .
|
All pointers |
32 |
4 (word-aligned) |
Not applicable. |
bool (C++ only) |
8 |
1 (byte-aligned) |
false or true |
_Bool (C onlya) |
8 |
1 (byte-aligned) |
false or true |
Type alignment varies according to the context:
Local variables are usually kept in registers, but
when local variables spill onto the stack, they are always word-aligned.
For example, a spilled local char variable has
an alignment of 4.
The natural alignment of a packed type is 1.
Integer
Integers are represented in two's complement form. The low
word of a long long is at the low address in
little-endian mode, and at the high address in big-endian mode.
Float
Floating-point quantities are stored in IEEE format:
For double and long double quantities
the word containing the sign, the exponent, and the most significant
part of the mantissa is stored with the lower machine address in
big-endian mode and at the higher address in little-endian mode.
Arrays and pointers
The following statements apply to all pointers to objects
in C and C++, except pointers to members:
Adjacent bytes have addresses
that differ by one.
The macro NULL expands to the
value 0.
Casting between integers and pointers results in
no change of representation.
The compiler warns of casts between pointers to
functions and pointers to data.
The type size_t is defined as unsigned
int .
The type ptrdiff_t is defined
as signed int .
|