I just did some experiments with an older version of CodeWarrior (68K). I
found that you could use:
#pragma pack(push, 1)
typedef struct {...} FooType;
#pragma pack(pop)
or:
#pragma options align=packed
typedef struct {...} FooType;
#pragma options align=reset
to eliminate padding. This allows sizeof(FooType) to be odd. However, the
code generated for accessing an unaligned field is the same as for an
aligned field: a simple move instruction. This will fail with an address
error on Poser or a real device (but not in the old Mac simulator).
The ADS ARM compiler has an __packed type qualifier that eliminates padding
and forces the compiler to generate code to do unaligned accesses. Several
instructions are needed in place of a single MOV instruction.
I don't know what GCC supports, either in 68K or ARM.
One thing's for sure: every compiler is different. If you want your code to
be compiler-neutral, you're better off packing and unpacking manually.
-
Danny
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/