ronald@robobar.co.uk (Ronald S H Khoo) (11/23/90)
Can someone give me a pointer to relevant bits of the Standard please ? I'd like to know if 1) I can have a strictly conforming portable function that returns the address of a structure, given the address of a member of said structure, 2) Is this function the one I want ? (and is it strictly conforming?) #include <stddef.h> /* typedefs to define type1 and type2 */ struct foo { type1 first_bit; type2 second_bit; }; struct foo * func(type2 *arg) { return (struct foo *) ((char *)arg - offsetof(struct foo, second_bit)); } -- ronald@robobar.co.uk +44 81 991 1142 (O) +44 71 229 7741 (H)