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]
Other format: [Raw text]

alignment/padding of structures


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++ ?


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