> From: Michael Anburaj > > I have very general compiler question. Since, there are a lot of experts > here, I am sure I will get an answer :) > > I see that most compiler follow this alignment rule for byte > arrays (I guess > structures too), that they get aligned at least on a 4byte boundary on a > 32bit machine (like ARM or MIPS32 & so on). > > I dont know if this alignment is an artifact of something else or the > tool-chain has a rule as such for doing so. > > Can anyone who is familiar with this, throw some light on this subject? > 1. I am curious to know if such a rule exists in C compilers? > 2. If so, what is it called? It will be great if you could > point me to some > matrial. > > Thanks a lot, > -Mike. > > Sample code: > > Char C1; > Char C2[8]; > Char C3; > > &C1 is equal to 0x800001 > &C2 is equal to 0x800004 > &C3 is equal to 0x800002
I don't think all compilers do that. I don't recall the old Borland x86 compiler doing that, and I used it for years. My guess is that this version does that in order to work better with functions like memset and memcpy, which generally play tricks to use full word memory accesses rather than byte accesses. -- Ciao, Paul D. DeRocco Paul mailto:[EMAIL PROTECTED] -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
