www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/29/16:22:49

X-Sender: dlanor AT mail DOT dds DOT nl
Message-Id: <l03130300b375f8976547@[145.98.116.66]>
Mime-Version: 1.0
Date: Sat, 29 May 1999 22:14:05 +0200
To: djgpp AT delorie DOT com
From: Dlanor Blytkerchan <dlanor AT dds DOT nl>
Subject: -fpack-struct
Reply-To: djgpp AT delorie DOT com

Hi all!

I have a small problem with getting my code to be compatible with some
other code I did not write. The problem is this: The code I did not write
was written in basic (QBX/PDS) and uses a TYPE definition (like "struct" in
C) of 107 bytes. This TYPE has two strings in it, one of which has a size
of three bytes. If I make the same TYPE in C like this:
typedef struct {
  (..)
} myStructure;
it is 108 bytes: there is an extra byte, as the struct members are
word-aligned. This is exactly the problem: getting it to be byte-aligned to
get it compatible with the basic code (as Basic reads/writes 107 bytes per
DB record to disk, and C reads/writes 108 bytes). Looking it up in the
compiler options, I found the option "-fpack-struct" that should do what I
want it to do: byte-align the structs. 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? If it is likely to cause problems, is
there another way to byte-align the struct that won't cause problems, or
should I write I/O code that cuts the struct in pieces when reading/writing
it to files?

Greetz!

Dlanor


- Raw text -


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