It's all explained in the MW docs.

The equivalent on Windows is the #pragma pack() directive

68k alignment is on 2 byte boundaries
PowerPC is on 4 bytes
not sure about 68k 4-byte

example:

struct
{
char field1; // 1 byte
short field2; // 2 bytes
char field3; // 1 byte
long field4; // 4 bytes
};

With 1 byte alignment, the above struct is 8 bytes. The problem is a
processor like the 68000 can't read words or longs at odd addresses.

With 2 byte alignment, the above struct is 10 bytes:
struct
{
char field1; // 1 byte
 // 1 byte filler inserted by compiler so following short is on even address
short field2; // 2 bytes
char field3; // 1 byte
 // 1 byte filler inserted by compiler so following long is on even address
long field4; // 4 bytes
};

With 4 byte alignment, the above struct is 12 bytes:
struct
{
char field1; // 1 byte
 // 1 byte filler inserted by compiler so following short is on even address
short field2; // 2 bytes
char field3; // 1 byte
 // 3 bytes filler inserted by compiler so following long is on double word
address
long field4; // 4 bytes
};
Aligning the long on a double word address (one that can use the 32 bits af
the address bus) ensures maximum speed with the PowerPC.

With the Palm, you should use 68k alignment.

Intel processors can read shorts or longs at any address. If you're using
structs with members of different sizes on both the Palm and the PC (for
conduit development), to ensure your struct has the same size on both
platform, either insert explicit fillers in your structs, or use the
compiler directives:

#pragma pack(push,2) // = 68k alignment

typedef... // insert your declarations there

#pragma pack(pop)

Good luck

Eric.

> De�: Oz Shalbar <[EMAIL PROTECTED]>
> R�pondre �: [EMAIL PROTECTED]
> Date�: Sun, 9 Jan 2000 15:44:34 +0200
> ��: "Palm Mailinglist (E-mail)" <[EMAIL PROTECTED]>
> Objet�: struct alignment
> 
> can anyone please tell me about struct alignment (in target settings->68K
> processor).
> waht is the difference between "PowerPC", "68K" and "68K 4-byte" ?
> 

Reply via email to