Cnews on System V/AT: "expression causes compiler loop"
Wm E Davidsen Jr
davidsen at crdos1.crd.ge.COM
Wed Nov 22 01:25:39 AEST 1989
In article <1989Nov20.181839.1546 at utzoo.uucp> henry at 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 at 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
More information about the Comp.unix.microport
mailing list