From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1682 invoked by alias); 9 Jan 2008 14:40:59 -0000 Received: (qmail 1674 invoked by uid 22791); 9 Jan 2008 14:40:58 -0000 X-Spam-Check-By: sourceware.org Received: from londo.lunn.ch (HELO londo.lunn.ch) (80.238.139.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 09 Jan 2008 14:40:31 +0000 Received: from lunn by londo.lunn.ch with local (Exim 3.36 #1 (Debian)) id 1JCc6S-0006Tn-00; Wed, 09 Jan 2008 15:40:24 +0100 Date: Wed, 09 Jan 2008 14:40:00 -0000 From: Andrew Lunn To: Alexandre Cc: ecos-discuss Message-ID: <20080109144024.GA24390@lunn.ch> Mail-Followup-To: Alexandre , ecos-discuss References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] pragma pack X-SW-Source: 2008-01/txt/msg00027.txt.bz2 On Wed, Jan 09, 2008 at 03:19:28PM +0100, Alexandre wrote: > Hi everybody (and happy new year would i add), > > I'd like to use the pragma pack(1) in one of my applications to align > properly a 5 bytes structures array into flash. > I know that packing reduces greatly the performances of the system but > performance is not really my problem here as i'm actually looking for > more memory and would greatly need to pack things up a little bit. > > I tried to declare the next structure as shown, with the pragmas, but > it's still 8 bytes large, either read with a sizeof(pelco_pattern) or > after being written in rom: > > #pragma pack(1) > typedef struct { > cyg_uint8 command2_byte; > cyg_uint8 data3; > cyg_uint8 data4; > cyg_uint16 timestamp; > } pelco_pattern; > #pragma pack() Is this legal for gcc? I always use attributes. Take a look at http://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Type-Attributes.html#Type-Attributes Andrew -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss