Article View: gnu.gcc.bug
Article #6328Re: structure size
From: Eli Zaretskii
Date: Tue, 19 Dec 1995 00:00
Date: Tue, 19 Dec 1995 00:00
20 lines
1387 bytes
1387 bytes
On Tue, 19 Dec 1995, Travis Bauer wrote: > The reason I discovered this is that I am writing code that needs to > be able to write data into oilday as a void pointer. In Borland's > Turbo C++, the structures had no extra bytes so I could calculate the > field positions in the variable as offsets from the base address of > oilday. But with the extra bytes in the structure, the calculation > does not hold true. You can tell the compiler to not align struct fields by using the __attribute__((packed)) extension of gcc; look it up in the Info docs. There is also the macro offsetof() which could help you to compute the byte offset of each field in the struct. This is ANSI C feature, so if you can use it to overcome your problems, I think it's better. Btw, your mailer seems to be badly set up: the headers come out messed up to such a degree that my mailer couldn't figure them out and I had to manually insert the addresses and the subject.
Technical Details
Message-ID:
<Pine.SUN.3.91.951219184557.11369B-100000@is>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,23ed274e9f2aff0b X-Google-Attributes: gid113d02,public From: eliz@is.elta.co.il (Eli Zaretskii) Subject: Re: structure size Date: 1995/12/19 Message-ID: <Pine.SUN.3.91.951219184557.11369B-100000@is> X-Deja-AN: 122393817 distribution: gnu sender: daemon@cis.ohio-state.edu organization: GNUs Not Usenet newsgroups: gnu.gcc.bug