X-Sender: dlanor AT mail DOT dds DOT nl Message-Id: In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sun, 30 May 1999 23:16:04 +0200 To: djgpp AT delorie DOT com From: Dlanor Blytkerchan 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 Precedence: bulk >Dlanor Blytkerchan 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 wrote: >You could try the FAQ first. I think this issue is well explained in >section 22.10 there. "Marp" 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