Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: comp.lang.c Subject: Re: offsetof (was Arithmetic on NULL) Message-ID: <2500@mmintl.UUCP> Date: Tue, 20-Oct-87 20:28:58 EDT Article-I.D.: mmintl.2500 Posted: Tue Oct 20 20:28:58 1987 Date-Received: Sat, 24-Oct-87 16:34:29 EDT References: <1459@cullvax.UUCP> <48400001@tub.UUCP> <1151@haddock.ISC.COM> <1076@jenny.cl.cam.ac.uk> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT. Lines: 20 In article <1076@jenny.cl.cam.ac.uk> am@cl.cam.ac.uk (Alan Mycroft) writes: |In article <1151@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer) wrt: |>> (char *)&((struct foo *)0)->bar - (char *)&((struct foo *)0)->baz |>Now, it may well be the case that "offsetof" is defined in to |>expand into the above mess, on machines where it happens to work. |I have a concern about this. ANSI (Oct 86) specifically disallows |unary-& from appearing in constant expressions (no doubt |except in sizeof() context). Thus offsetof cannot expand into |the above mess since it has to be a constant expression, e.g. for |initialisers. I don't have a copy of the proposed standard available, but I would guess that it does *not* disallow unary & in constant expressions. I would guess that, instead, it merely does not require that use of unary & be supported. So a compiler writer would be perfectly free to support it, and then implement offsetof in this way. -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108