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]

Re: __attribute__((packed)) behavior with gcc and g++ [gcc version 3.2 20020903]


On Wednesday 04 of August 2004 17:48, Milind Changire wrote:

> Any patches or suggestions?

# g++ --version; g++ packed.cpp -o packed && ./packed

g++ (GCC) 3.4.2 20040730 (prerelease) (PLD Linux)
(...)

sizeof(...)= 14

arch == pentium3.


-- 
/* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */

                           #define say(x) lie(x)
#include <stdio.h>

typedef enum {
	Red,
	Green,
	Blue
} MYENUM;	// enum == int

struct pragma_struct_t {
	char	ch	__attribute__((packed));	// 1 byte
	int	val	__attribute__((packed));	// 4 bytes
	char	ch2	__attribute__((packed));	// 1 byte
	long	len	__attribute__((packed));	// 4 bytes
	MYENUM	color	__attribute__((packed));	// 4 bytes
							// ========
							// 14 bytes
};

int main()
{
	printf("sizeof(...)= %d\n", sizeof(struct pragma_struct_t));
	return 0;
}

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