29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C and C++ Implementation Details<br />

Packed structures<br />

A packed structure is one where the alignment of the structure, and of the fields within<br />

it, is always 1.<br />

Packed structures are defined with the __packed qualifier. There is no command-line<br />

option to change the default packing of structures.<br />

Bitfields<br />

In non-packed structures, the <strong>ARM</strong> compiler allocates bitfields in containers. A<br />

container is a correctly aligned object of a declared type.<br />

Bitfields are allocated so that the first field specified occupies the lowest-addressed bits<br />

of the word, depending on configuration:<br />

Little-endian<br />

Big-endian<br />

Lowest addressed means least significant.<br />

Lowest addressed means most significant.<br />

A bitfield container can be any of the integral types.<br />

Note<br />

In strict 1990 ISO Standard C, the only types permitted for a bit field are int, signed<br />

int, and unsigned int. For non int bitfields, the compiler displays an error.<br />

A plain bitfield, declared without either signed or unsigned qualifiers, is treated as<br />

unsigned. For example, int x:10 allocates an unsigned integer of 10 bits.<br />

A bitfield is allocated to the first container of the correct type that has a sufficient<br />

number of unallocated bits, for example:<br />

struct X<br />

{<br />

int x:10;<br />

int y:20;<br />

};<br />

The first declaration creates an integer container and allocates 10 bits to x. At the second<br />

declaration, the compiler finds the existing integer container with a sufficient number<br />

of unallocated bits, and allocates y in the same container as x.<br />

A bitfield is wholly contained within its container. A bitfield that does not fit in a<br />

container is placed in the next container of the same type. For example, the declaration<br />

of z overflows the container if an additional bitfield is declared for the structure:<br />

5-10 Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DUI 0348A<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!