The structure alignment is on the Code Generation 68K processor page. "Struct Alignment". The #pragma pack(n) can set this in code. See the help for more info.

I don't see any obvious packing issues, usually even causes less problems.

Another problem with the second structure is the large size, if it is created on the stack and not the heap. Palm devices typically have relatively small stacks.

Glen Peters wrote:
Are you referring to 16 bit alignment? Where can I read up on this alignment issue? I have never found it in the API or in the Companion. Here are a couple examples of my structures:
typedef struct
{
    UInt32 ID_One;
    UInt32 ID_Two;
    UInt8 Status_One;
    UInt8 Status_Two;
    Char String_One[50];
    Char String_Two[15];
    Char String_Three[15];
} Sample1; //this structure is part of the original union that worked without issues

typedef struct
{
    UInt32 TimeStamp;
    UInt32 Size;
    Char ID[22];
    Char BigArray[1006];
} Sample2; //this structure was added to the union and is causing problems

I neglected to mention that not only was I reorganizing the union members order but I was adding new members. I guess the string size factors into the alignment issue since I am setting a fixed size for the array right? I discovered today that if I remove the Sample2 structure from the union that everything seems to be normal again. Correct me if I am wrong but if the UInt variables total memory usage is divisible by 16 then that part should be fine. In addition, since Chars are 8 bit, the total number of Chars needs to be divisible by 16 as well right?

Glen


"Jim Morris" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Did you check for structure packing and possible alignment issues?

Glen Peters wrote:
I have a union of structures inside of a structure. This outer structure is used as a "packet" to be sent via a NetLib socket. If I change the order of the structures in the union, recompile and test I have problems. When I debug using Palm OS Debugger I find that the app crashes during the closure of the application in the assembly following the return from PilotMain. If I restore the union to it's original state and order, it works again without crashing. Any thoughts on how to fix this? It will also crash sometimes when the structure containing the union is in scope and I call NetLibOpen. Pretty wacky if you ask me.

Glen Peters







--
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to