gcc and NULL function pointers.

Norman Diamond diamond at jit533.swstokyo.dec.com
Fri Jun 21 13:35:08 AEST 1991


In article <9752 at cognos.UUCP> jimp at cognos.UUCP (Jim Patterson) writes:
>Which is why there should be a standard definition. It avoids suprises
>when porting to new environments.

Correct coding avoids most surprises.  If a correctly written program gets
a surprise, ask the compiler vendor for a refund.
(DISCLAIMER:  This is personal opinion; my emplyer did not write this.)

>Except for the substantial prior art for #define NULL (0), I think
>(void*)0 is ALWAYS the best definition.
>Of course, prior art is an important consideration, so I can't fault
>the X3J11 group for leaving the definition somewhat ill-defined, but
>if it were designed again from scratch I think the argument for 
>#define NULL (0) would be pretty weak.

If C were designed again from scratch, it might have (void*) from scratch.
Remember, a lot of null pointers were coded when C didn't have (void*)?
Also, if C were designed again from scratch, NULL might be a reserved word,
built into the language like in every other language that has pointers,
instead of being #defined in terms of anything.

Also, if C were designed again from scratch, it wouldn't be C.  Kernighan
and Ritchie would probably be willing to apply lessons of the 70's.
--
Norman Diamond       diamond at tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.



More information about the Comp.std.c mailing list