At 11:49 PM 3/30/06 +0000, dsidlauskas1 wrote:
>ints are not always word aligned. For example:
>
>#pragma packed(1)
>struct eg
> {
> char x;
> int y;
> char z;
> int w;
> }test;
>
>One of the integers in this structure is not word word aligned and yet
Only if the compiler understands pragma packed(1) to mean byte alignment in
the following structure. Far from a sure thing. The compiler is quite
allowed to insist that items be aligned on particular boundaries and for
certain architectures to get decent performance they must. Code that
depends on the alignment is at the very least non-portable. If you are
porting from an 8 bit compiler as you indicated in another post then you
also have to worry about sizes. the size of that structure on an compiler
in the most common 8 bit implementations would be 6 bytes. On an ARM
implementation it would be 16 bytes (6 of them would be padding). If the
compiler happened to understand the pragma it might bring it down to 10 bytes.
RobertMessage
Re: [lpc2000] Re: For C Experts
2006-03-31 by Robert Adsett
Attachments
- No local attachments were found for this message.