sizeof different in x86 and arm.
Wiesner, Robert
robert.wiesner@intel.com
Thu May 24 08:20:00 GMT 2001
Hi,
the structure layout and alignement is implementation defined. You may never
make any asumption about the structure layout within the memory or the site
of the structures. E.g.:
struct x {
int a;
char b;
int c;
char d;
};
what is the size of this structure? Is it 32 byte (64 bit alignement), 16
byte (32 bit alignement), 8 byte (16 bit integer) or may be 10 bytes? Does
the memory layout looks like
a a a a b c c c c d
or
a a a a c c c c b d
Since this is also implementation defined. Also the organization of global /
local symbols.
My suggestion is, that the correct way to exchange data between differnet
systems (Compiler / CPUs) is to with and read a byte stream. Most of the
(embedded) compiler also support an alignement directive for structures. So
in this case you can force the alignement for specific structures.
The x86 CPU support missaligned memmory accesses (int on a none 4 byte
aligned boundary) while the ARM CPU doesn't support something like this.
Also it is better for the data access, if the start address is 4 bytes
aligned in both cases.
CU,
Robert
-----Original Message-----
From: Cliff Tsai [ mailto:clifftsai@minecard.com.tw ]
Sent: Thursday, May 24, 2001 3:42 AM
To: crossgcc
Subject: sizeof different in x86 and arm.
Hi:
I have a simple struct as follow
struct test_align
{
unsigned char Name[21];
unsigned char Version[8];
};
But on cygwin for x86,the sizeof(struct test_align) is 29;
but on cygwin for arm,the sizeof(struct test_align) return 32
WHY.
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to
crossgcc-unsubscribe@sourceware.cygnus.com
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
More information about the crossgcc
mailing list