Mail Archives: djgpp/1999/05/30/11:18:12
From: | "Marp" <Marp AT 0 DOT 0 DOT 0 DOT 0>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: -fpack-struct
|
Date: | Sat, 29 May 1999 21:43:35 -0400
|
Organization: | Netcom
|
Lines: | 41
|
Message-ID: | <7iq54a$lu7@sjx-ixn5.ix.netcom.com>
|
References: | <l03130300b375f8976547@[145.98.116.66]>
|
NNTP-Posting-Host: | prn-nj3-25.ix.netcom.com
|
X-NETCOM-Date: | Sat May 29 6:43:38 PM PDT 1999
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2014.211
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2014.211
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
You can use __attribute__((packed)) instead. For example:
typedef struct {
members go here
} myStructure __attribute__((packed));
Dlanor Blytkerchan <dlanor AT dds DOT nl> wrote in message
news:l03130300b375f8976547@[145.98.116.66]...
> 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 -