From: "John S. Fine" Newsgroups: comp.os.msdos.djgpp Subject: Re: Strange pointer manipulation Date: Tue, 26 Jan 1999 10:40:13 -0500 Lines: 23 Message-ID: <36ADE1DD.13B@erols.com> References: <36AD11AA DOT 3876 AT erols DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: XRY2HSA4HPy2NKrUeCYMMkqoEzLbb1bAkPfIqmHPB6g= X-Complaints-To: abuse AT rcn DOT com NNTP-Posting-Date: 26 Jan 1999 15:41:27 GMT X-Mailer: Mozilla 3.01 (Win95; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com DeHackEd wrote: > There is a built-in C command called offsetof(struct, entry). Eli Zaretskii wrote: > No need for any GCC-specific magic: `offsetof' is ANSI C. It's > amazing how many people miss that feature. Thankyou both. That is exactly what I needed. I have been programming C for many years, frequently wanted that feature and never knew it was available. BTW, after I got your messages, it took me a little while to figure out why it didn't initially work. Given the name, I was able to do a search and find it in stddef.h. (once I include stddef.h it works). It turns out it is a macro and it uses a method similar to the one I tried. It just does it in a slightly cleaner way that doesn't confuse the GCC optimizer, the way mine did. -- http://www.erols.com/johnfine/ http://www.geocities.com/SiliconValley/Peaks/8600/