From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16127 invoked by alias); 21 Dec 2009 08:31:45 -0000 Received: (qmail 16118 invoked by uid 22791); 21 Dec 2009 08:31:45 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from mx0.acri.fr (HELO mx0.acri.fr) (213.244.27.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Dec 2009 08:31:38 +0000 Received: from [194.98.101.80] (pim106.acri.fr [194.98.101.80]) by mx0.acri.fr (8.13.6/8.13.6) with ESMTP id nBL8VTGj002636 for ; Mon, 21 Dec 2009 09:31:29 +0100 (CET) Message-ID: <4B2F325E.10709@acri-st.fr> Date: Mon, 21 Dec 2009 09:22:00 -0000 From: Cedric Roux User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Re: Need help using gcc in command line mode. References: <1261236913_110979@mail01> <4B2D069D.9080100@htw-berlin.de> In-Reply-To: <4B2D069D.9080100@htw-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Synonym: Archived With Synonym to: mailcopy@dingo.acri.fr X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2009-12/txt/msg00292.txt.bz2 Thomas Martitz wrote: > Try appending __attribute__((packed)) after the closing } of the structs > in question. That should disable padding. > > Furthermore I recommend using int32_t instead of long, since long is 8 > bytes on 64-bit Linux systems (hence your code wouldn't work on those). > > Best regards. You can also compile with -fpack-struct (see "man gcc") But may I suggest that you read your file byte by byte and feed the structures by reconstructing data with those bytes (like "x = c1 | (c2 << 8) | (c3 << 16)" or something)? It is the most portable solution and if your programs don't spend all of their time in reading these headers then there is no need to "optimize." (And you won't waste a lot of time debugging in that direction...) Regards, Cédric.