Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site wateng.UUCP Path: utzoo!watmath!wateng!padpowell From: padpowell@wateng.UUCP (PAD Powell) Newsgroups: net.lang.c Subject: proposed new construct, offsetof() Message-ID: <1583@wateng.UUCP> Date: Wed, 24-Oct-84 10:24:28 EDT Article-I.D.: wateng.1583 Posted: Wed Oct 24 10:24:28 1984 Date-Received: Thu, 25-Oct-84 02:40:32 EDT Organization: U of Waterloo, Ontario Lines: 20 I have just been burned again, by a C compiler, and a structure. I propose the following construct to be added to C: offsetof( structure_name.field.field.... ) Given the name of the stucture, and the list of the fields, returns the integer value of the offset from the beginning of the structure, that will be used in accessing the particular field. 1. This is useful in DEBUGGING, and finding if you have portable code. I have just been burned with 16/32 bit integers. 2. It provides a "hook" into the compiler which will eliminate all the ugly arguements about "offset calculations using 0 pointers" which is raging. 3. In my personal opinion, it is a solution to a problem that requires looking at object code, and then guessing what the offset is. Patrick ("Whimper! first the optimizer gets me, now the structures") Powell