From: Cedric Roux <cedric.roux@acri-st.fr>
To: gcc-help@gcc.gnu.org
Subject: Re: Need help using gcc in command line mode.
Date: Mon, 21 Dec 2009 09:22:00 -0000 [thread overview]
Message-ID: <4B2F325E.10709@acri-st.fr> (raw)
In-Reply-To: <4B2D069D.9080100@htw-berlin.de>
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.
next prev parent reply other threads:[~2009-12-21 8:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-19 17:00 Gene Creighton
2009-12-19 17:09 ` Thomas Martitz
2009-12-21 9:22 ` Cedric Roux [this message]
2009-12-21 17:00 ` Andrew Haley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B2F325E.10709@acri-st.fr \
--to=cedric.roux@acri-st.fr \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).