04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

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.

Compiler-specific Features<br />

Restrictions<br />

The following restrictions apply to the use of __packed:<br />

• The __packed qualifier cannot be used on structures that were previously declared<br />

without __packed.<br />

• Unlike other type qualifiers you cannot have both a __packed and non-__packed<br />

version of the same structure type.<br />

• The __packed qualifier does not affect local variables of integral type.<br />

• A packed structure or union is not assignment-compatible with the corresponding<br />

unpacked structure. Because the structures have a different memory layout, the<br />

only way to assign a packed structure to an unpacked structure is by a<br />

field-by-field copy.<br />

• The effect of casting away __packed is undefined. The effect of casting a non<br />

packed structure to a packed structure is undefined. A pointer to an integral type<br />

can be legally cast, explicitly or implicitly, to a pointer to a packed integral type.<br />

You can also cast away the __packed on char types.<br />

• There are no packed array types. A packed array is an array of objects of packed<br />

type. There is no padding in the array.<br />

Example<br />

Example 4-4 shows that a pointer can point to a packed type.<br />

Example 4-4 Pointer to packed<br />

typedef __packed int* PpI; /* pointer to a __packed int */<br />

__packed int *p; /* pointer to a __packed int */<br />

PpI p2; /* 'p2' has the same type as 'p' */<br />

/* __packed is a qualifier */<br />

/* like 'const' or 'volatile' */<br />

typedef int *PI; /* pointer to int */<br />

__packed PI p3; /* a __packed pointer to a normal int */<br />

/* -- not the same type as 'p' and 'p2' */<br />

int *__packed p4; /* 'p4' has the same type as 'p3' */<br />

Example 4-5 on page 4-13 shows that when a packed object is accessed using a pointer,<br />

the compiler generates code that works and that is independent of the pointer alignment.<br />

4-12 Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. <strong>ARM</strong> DUI 0348C<br />

Non-Confidential,<br />

ID101213

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

Saved successfully!

Ooh no, something went wrong!