Xref: utzoo news.software.b:3614 comp.unix.microport:3850 Path: utzoo!attcan!uunet!samsung!brutus.cs.uiuc.edu!rpi!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: news.software.b,comp.unix.microport Subject: Re: Cnews on System V/AT: "expression causes compiler loop" Message-ID: <1676@crdos1.crd.ge.COM> Date: 21 Nov 89 14:25:39 GMT References: <3056@splut.conmicro.com> <1989Nov20.181839.1546@utzoo.uucp> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Followup-To: news.software.b Organization: GE Corp R&D Center, Schenectady NY Lines: 24 In article <1989Nov20.181839.1546@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: | The offsetof() macro has a tendency to stress-test compilers. Try: | | #define offsetof(type, mem) ((int)&((type *)NULL)->mem) | | as an alternative. I would be very careful using this. Althoug I feel that the use of a zero cast to a non-void type is legal in sizeof, because of qualifying statements promising that it is not evaluated, I would not be surprized to see a compiler reject this one. I see how it works, I realize that it will work on many compilers, but I am suspicious that it is not really portable. I would put the definition in ifdefs at the very least, so that the required offsetof macro could be used on undamaged compilers. The error message reminds me of things I used to get out of MSC some years ago. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon