Re: offsetof() macro




There are those who advocate using 0 rather than the NULL macro as a null pointer constant. They are, of course, wrong, since they disagree with me.

(If I were designing the language from scratch, there would be a
keyword, either "nil" or "null", that would be the *only* null pointer
constant.  Using 0 in a pointer context would be a constraint error.

What do you mean by "using 0 in a pointer context"? In another post you have said "An integer constant 0 is a valid null pointer constant. If you assign a null pointer constant to a pointer object, that object's value at execution time will be a null pointer."+"The macro NULL expands to a null pointer constant." And now you say that using 0 is a constraint error. I think I haven't understood yet :-(


And on every compiler I've tried, int *pt=0; works without errors or warnigs. And also the standard says that a constant expression evaluating to 0 or such an expression cast to void*, assigned to a pointer of wathever type makes it a null pointer.

Sorry if I'm wasting your time, but I'm a bit confused...

--
Devaraja (Xdevaraja87^gmail^c0mX)
Linux Registerd User #338167
http://counter.li.org
.



Relevant Pages

  • Re: segfault on strtok
    ... >>A constant expression with a value of zero, ... > I was looking at the standard when I wrote it. ... > integer which is zero is a null pointer constant if cast to void *. ...
    (comp.lang.c)
  • Re: segfault on strtok
    ... > integer which is zero is a null pointer constant if cast to void *. ... > a pointer type. ... An integer constant expression with the value 0, ...
    (comp.lang.c)
  • Re: Compiler error or? Microsoft VC++ v6.0
    ... The rule says that a null pointer constant is a ... >> constant expression evaluating to zero. ... >> constant qualifies as a constant expression. ... I'm Schobi at suespammers dot org ...
    (microsoft.public.vc.language)
  • Re: Compiler error or? Microsoft VC++ v6.0
    ... The rule says that a null pointer constant is a ... > constant expression evaluating to zero. ... > constant qualifies as a constant expression. ...
    (microsoft.public.vc.language)
  • Re: offsetof() macro
    ... [DevarajA: please preserve attribution lines, ... Using 0 in a pointer context would be a constraint error. ... >have said "An integer constant 0 is a valid null pointer constant. ...
    (comp.lang.c)

Loading