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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux