delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/26/11:52:11

From: "John S. Fine" <johnfine AT erols DOT com>
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> <wy9r2.317$hd7 DOT 69 AT tundra DOT ops DOT attcanada DOT net>
Mime-Version: 1.0
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 <eliz AT is DOT elta DOT co DOT il> 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/

- Raw text -


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