delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/30/17:30:00

X-Sender: dlanor AT mail DOT dds DOT nl
Message-Id: <l03130303b377583e9541@[145.98.116.90]>
In-Reply-To: <Pine.SUN.3.91.990530122140.12571Y-100000@is>
References: <l03130300b375f8976547@[145.98.116.66]>
Mime-Version: 1.0
Date: Sun, 30 May 1999 23:16:04 +0200
To: djgpp AT delorie DOT com
From: Dlanor Blytkerchan <dlanor AT dds DOT nl>
Subject: Re: -fpack-struct
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

>Dlanor Blytkerchan <dlanor AT dds DOT nl> wrote:
>> My problem is this: the gcc info file says: "the offsets of the structure
>> members won't agree with system libraries". This is what worries me: what
>> does this mean and how likely is it that this will cause problems?

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
>You could try the FAQ first.  I think this issue is well explained in
>section 22.10 there.

"Marp" <Marp AT 0 DOT 0 DOT 0 DOT 0> wrote:
>You can use __attribute__((packed)) instead. For example:
>
>typedef struct {
>    members go here
>} myStructure __attribute__((packed));

ams AT ludd DOT luth DOT se (Martin Str|mberg) wrote:
>This is how I would attack the problem-
>Step 1.  Figure out the byte sequence. You need to know what bytes is
>         where in your data type.
>Step 2.  When you know this, you can memcpy() the data you need to
>         the data types that you have defined.

I'm sorry: I don't mean to be picky or rude, but this doesn't help me much.
Naturally I checked the FAQ first, which didn't help me much, as it
recommends using an alternative sequence of members or the
__attribute__((packed)) thingy, which amounts to the same thing as using
the -fpack-struct compiler option. Altering the sequence of the structure
members is simply not an option, as it was set by the author of the program
my program has to be compatible with. As using the __attribute__((packed))
thingy amounts to the same thing as using the -fpack-struct compiler
option, that does not take away my reservations for using this. Added to
that, C++ will not allow this syntax, which does not cause problems yet,
but probably will in the future.
The third option sent as a reply is the one I'm already using, as the
method I intended to use simply worries me too much - though is in my view
still the more elegant one. I already know the byte order of the struct,
and am now using a char array as IO buffer from where I copy the date into
my struct, accounting for the paddings, when I read, and to which I copy
data from my struct when I write. I had hoped not to be stuck with such a
workaround, but as my question remains unanswered, I guess I am.

Thanx for your response anyway: after all, even an answer one is not
looking for is more than no answer..

Greetz!

Dlanor


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019