This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: sizeof and alignement


> Generally only few bytes (4, 8, 12...). We think this is due to the
> memory alignment that is forced in the Sun platform. ... Is there
> any way for solving this problem ?

It's hard to tell whether there is a solution, without seeing the
specific structures in question. For example, your analysis that
memory alignment is the cause could be incorrect, in which case
proposals for solutions would be on the wrong track.

> Can we force the gcc compiler to modify the alignment of the
> produced code ?

To a limited degree, yes; there is a specific __attribute__
declaration for that. Please have a look in the GCC manual, (gcc)Type
Attributes.

> Where can we find information about this common problems when
> porting applications ?

The problem is not as common as you think. Because of the problems,
many people avoid exchanging ad-hoc binary data.

Even if you get sizes and alignment right, you still have to fight
endianness: Sparc is big-endian, Intel little-endian. That means all
the values will be incorrect.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]