Mail Archives: djgpp/1999/01/26/11:52:11
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 -