[uClinux-dev] structure size ????
petero at cvs.com.au
Sun Mar 2 22:11:32 EST 2003
I had to solve this a little while ago, you might want to
look in the archive for the subject
Platform independant structs
There was a couple of suggestions made, which fit different
circumstances. The solution I used is below.
Below is an example of a struct which is padded so all the data
is on four byte boundaries. The __attribute((packed)) ensures
that there is no additional padding added by the compiler.
Since pad1 and pad2 may not be correctly aligned (depending
on where the code is running) you cant use them. You have to
chose the padding size so the data can be accessed on both
Hope this helps
__u8 pad1; // padding to preservefour byte alignment dont use
thomas chen wrote:
> i have a structure that is 10 bytes long... on the target side
> (arm) arm-elf-gcc expand that to multiple of 4, ie 12 bytes...
> but on the intel pc side, it is still 10 bytes... any way to pack
> the structure but without violating the arm alignment problem...
> ie if the structure is 9 byte long, i want to pack it to 10 instead
> of just 9....
> uClinux-dev mailing list
> uClinux-dev at uclinux.org
> This message was resent by uclinux-dev at uclinux.org
More information about the uClinux-dev