C++? when did that happen?

Tim Angus tim at ngus.net
Wed Oct 5 19:37:05 EDT 2005


On Thu, 06 Oct 2005 00:55:13 +0200 Ian wrote:
> In C you do NULL, since NULL could be defined in several ways.
> Apparently compilers these days workaround such things if you just put
> 0 there. All i said was that 0 is a C++:ism, which it is.
> (and it's not like a cast takes time in c)

0 is a "C++ism" because of C++'s tighter type checking, and does not
imply 0 is wrong in C. In other words, 0 is used in place of NULL
because there are situations in C++ where from a type checking point of
view, the use of NULL (where it is potentially defined as (void *)0) is
incorrect.

I'll say again, using 0 in place of NULL in C is perfectly valid and
correct. Yes, NULL is implementation defined, but that DOES NOT make the
use of 0 in place of NULL wrong, nor does it make it a "C++ism".

> A random adress in the variable is much worse since it could
> theoretically execute code that shouldn't be run and take time to
> debug.

If you think 0 is a "random address", /you're/ just plain wrong. Why
don't you try deferencing a function pointer set to 0 and see what
happens? May I politely suggest you go and read the C standard? ;)



More information about the quake3 mailing list