This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((packed)) behavior with gcc and g++ [gcc version 3.2 20020903]
- From: Paweł Sikora <pluto at pld-linux dot org>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 4 Aug 2004 17:58:36 +0200
- Subject: Re: __attribute__((packed)) behavior with gcc and g++ [gcc version 3.2 20020903]
- References: <1091634515.9797.49.camel@mitelLinux>
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;
}