[svlug] Structure Field Offset Measurement
shaeffer at best.com
Sat Jan 6 23:24:02 PST 2001
On Sat, Jan 06, 2001 at 10:16:16PM -0800, Anmol Khirbat wrote:
> On Sat, 6 Jan 2001, Karen Shaeffer wrote:
> > Actually, here we have NULL defined in stddef.h as
> > #define NULL ((void *)0)
> > And the MACRO uses an explicit zero. So, the compiler may or may not
> > interpret that explicit zero as NULL prior to the compile-time evaluation of
> > the MACRO.
> 1. NULL is a *MACRO*. It is handled by the preprocessor. The preprocessor
> replaces NULL by 0 or ((void*)0).
> 2. The *compiler* never even sees the token NULL
I am aware of this. My post isn't clear, thanks for clarifying it. It
doesn't change the result though. At least not in this instance with gcc.
> 4. Using 0 doesn't mean that the bit-pattern that the compiler generates
> to represent null pointers is all zero bits.
Yes, I know. But the compiler has to convert this from the all-bit zero
value to whatever during the compile-time processing. The basis of my
position is that gcc would do that during the generation of run-time code.
In this instance, gcc will not generate run-time code. The expression is
evaluated as a compile-time operation and run-time code is not generated. So
point #4 is not a factor here. At least not with gcc and Linux on X86.
I assure you it's not a problem--it works. It is actual code from <stddef.h>
If point #4 was a factor here--then that MACRO would fail. Think about it.
Thanks for your comments.
Neuralscape; Santa Cruz, Ca. 95060
shaeffer at neuralscape.com http://www.neuralscape.com
More information about the svlug