The alignment is determined by the processor, but you may be able to force a higher alignment with the compiler.
Generally, you do not need to worry about alignment. The problem is when you store data on one system and read it on another, or transfer data between systems. You should use operators like sizeof(), and OffsetOf() so that you never need to know the placement of structure fields. When read or writing to packed storage data, you should read or write each type individually, so you determine the alignment of the stored data, independent of the system. Note that you cannot access the packed bytes using typed references, e.g. MemPtr *p; UInt16 i; *i = *p; because i must be aligned. You must use copy commands. I don't know what the problem was with your AppInfo, but I suspect you were assigning a typed reference to point into your app info data which wasn't aligned. Matt ----- Original Message ----- From: "David Beers" <[EMAIL PROTECTED]> To: "Palm Developer Forum" <[EMAIL PROTECTED]> Sent: Friday, May 30, 2003 1:09 AM Subject: Re: AppInfo alignment problem (was: Nested structure does not compile) > Matt Hebly wrote: > "With 16 bit alignment, only single byte types may be accessed in memory not > aligned to 16 bits. 2 and 4 byte types must be aligned on 16 bit boundaries. > Similarly, with 32 bit alignment, 4 byte types must be aligned on 32 bit > boundaries." > > When you say "with 16 bit alignment" or "with 32 bit alignment," are these > options that are in my control or is this a feature of the processor/system? > Do I just avoid putting 1-byte types in my AppInfo and record structures, > always pair up a byte with another unused byte when I do, or is there > another option available? > > Thanks > David > > > -- > For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
