[lug] OFF: sizeof structs in gcc?

Alan Robertson alanr at unix.sh
Thu Jun 7 22:52:43 MDT 2001


Sebastian wrote:
> 

> Yes. GCC by default alligns structures to the native boundry for the cpu the
> code is compiled.  32 bits on most 32 bit platforms like x86 ( 386+).  You
> can alter the default alignment using #pragma directives in your source.
> This is done for speed.  On a 32 bit machine a "mov" instruction can move 32
> bits of data as fast as 16bits of data. ( ie: in a single instruction )  Of
> course this is done at the cost of memory usage.

Some machines fault when given fetch/stores on odd boundaries, so this not
always for speed alone - but to make the software work (not fault).

	-- Alan Robertson
	   alan at unix.sh



More information about the LUG mailing list