From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9337 invoked by alias); 16 Jul 2002 09:19:48 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 9327 invoked from network); 16 Jul 2002 09:19:46 -0000 Received: from unknown (HELO wh2-19.st.uni-magdeburg.de) (141.44.162.19) by sources.redhat.com with SMTP; 16 Jul 2002 09:19:46 -0000 Received: by wh2-19.st.uni-magdeburg.de (Postfix, from userid 1000) id DA2FA9FA5; Tue, 16 Jul 2002 11:19:49 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15667.58677.480682.649002@wh2-19.st.uni-magdeburg.de> Date: Tue, 16 Jul 2002 02:19:00 -0000 From: "Claudio Bley" To: "gcc-help@gcc.gnu.org" Subject: Re: help: sizeof(struct) In-Reply-To: References: X-SW-Source: 2002-07/txt/msg00144.txt.bz2 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "lium" == lium writes: lium> Hi, there is a struct like following: lium> struct test { unsigned char a; unsigned int b; lium> unsigned char c; } my target machine is ARM7TDMI, my gcc lium> version is: "gcc version 3.0". when i use sizeof(struct lium> test), it return 0xc. if i add 'packed' attribute, sizeof lium> return 6. but i need the sizeof macro return 9. You may use the following code: struct test { unsigned char a ; int : 24; /* unused */ unsigned int b; unsigned char c; } __attribute__((__packed__)); HTH Claudio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.6 iD8DBQE9M+U1TpSishmp0ioRAgoDAJ9/z6y3gex7k2v9/vsv+2nNUlx2ngCdHpNX ptM859EgQil6Yie2gmrWPSk= =4Ul3 -----END PGP SIGNATURE-----