Something new for C?

Super user root at dsoft.UUCP
Tue Nov 8 09:40:07 AEST 1988


Maybe I've missed something in C, but One of the things I've never found a way
to do and have always wanted, was a precompiler command to allow me to use
the offset of an item into a structure. for example:

struct test {
   long this;
   int  that;
   char those[8];
};

   val = offset(test,that);

As it is now, I have the choice to either recalculate the offset of a var in
a structure, or write it into the program source. 

(EG: offs = &test.that - &test.this)

I find myself building massive structures and constantly moving the data around
within them, but I need to know the offset of certain variables to use as 
key table entries in a keyed file system I wrote.  I'd like to have a way
not to have to recalculate the offset into a structure every time I make
a change.  It can get very harrowing at times!

Is there such a function already? or is there any plans for one?



More information about the Comp.lang.c mailing list