3.3.2. Basic data types

This section gives information about how the basic data types are implemented in ARM C and C++.

Size and alignment of basic data types

Table 3.3 gives the size and natural alignment of the basic data types. Type alignment varies according to the context. (See Structures, unions, enumerations, and bitfields.)

  • Local variables are usually kept in registers, but when local variables are spilled 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.

Table 3.3. Size and alignment of data types

TypeSize in bitsNatural alignment in bytes
char81 (byte-aligned)
short162 (halfword-aligned)
int324 (word-aligned)
long324 (word-aligned)
long long644 (word-aligned)
float324 (word-aligned)
double644 (word-aligned)
long double644 (word-aligned)
All pointers324 (word-aligned)
bool (C++ only)324 (word-aligned)

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:

  • float values are represented by IEEE single-precision values

  • double and long double values are represented by IEEE double-precision values.

If softvfp, vfp, or softvfp+vfp is selected, 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. See Operations on floating-point types for more information.

ARM implements an ANSI extension for floating-point constants (see Hexadecimal floating-point constants).

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.

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D
Non-Confidential