alignment/padding of structures

Frederic Christen Christen@fka.de
Thu Jan 24 08:36:00 GMT 2002


I've a problem in understanding the behaviour of
alignment and padding between MSVC++ and gcc-2.9.95 (Linux).

example:

struct foo {
	double a;
	double b;
	float c;
};

with MSVC++ and #pragma pack(4) set : sizeof(foo) = 20
with MSVC++ and #pragma pack(8) set : sizeof(foo) = 24
(the alternative Zp'x' flag causes the same effect)

but with gcc there is no effect of the #pragma:
with gcc and #pragma pack(4) set : sizeof(foo) = 20
with gcc and #pragma pack(8) set : sizeof(foo) = 20

Which compiler-flag has to be set to get the same alignment/
padding as with MSVC++ ?



More information about the Gcc-help mailing list