EmbeddedRelated.com
Forums

ARM typedefs using Keil

Started by Sutton Mehaffey January 22, 2013
From Keil uVision Help File:

Basic data types
ARM Compiler toolchain v5.02 for Vision Compiler Reference

This following basic data types are implemented in ARM C and C++:

Size and alignment of basic data types
Table 32 gives the size and natural alignment of the basic data types.

Table 32. Size and alignment of data types

Type Size in bits Natural alignment in bytes
char 8 1 (byte-aligned)
short 16 2 (halfword-aligned)
int 32 4 (word-aligned)
long 32 4 (word-aligned)
long long 64 8 (doubleword-aligned)
float 32 4 (word-aligned)
double 64 8 (doubleword-aligned)
long double 64 8 (doubleword-aligned)
All pointers 32 4 (word-aligned)
bool (C++ only) 8 1 (byte-aligned)
_Bool (C only[a]) 8 1 (byte-aligned)
wchar_t (C++ only) 16 2 (halfword-aligned)
[a] stdbool.h can be used to define the bool macro in C.


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.

See Structures, unions, enumerations, and bitfields for more information.

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.
However, it would be better to use the standard definitions from stdint.h header file, to be more portable.

Regards,

Alex
--- In l..., Sutton Mehaffey wrote:
>
> Anybody have any input on this issue?
>
> Keil has 'char', 'short', 'int', and 'long long' defined in their
> typedef.h file for ARM. I also see quite a few definitions in their
> header files of single 'long'. I assume that a single 'long' is the
> same as an 'int' in this case. At least that's what the Keil debugger
> displays when monitoring data. But, I wanted to be sure, because I
> don't see any typedefs for a long in any of the header files. Any
> comments? Thanks.
> --
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr.
> Kennesaw, GA 30144
> 770-514-7999, 800-207-6269
> Fax: 770-514-1285
> http://www.lookoutportablesecurity.com
> sutton@...
>

An Engineer's Guide to the LPC2100 Series