NULL Undeclared !?

Started by
15 comments, last by GameDev.net 18 years ago
<<Who cares? Only kids out of college use NULL. Real programmers use 0.>>

Blink. I avoid using any number where ever possible as 0 can mean true or false or success or failure or valid or invalid... Though I've been told I'm wierd before...
- My $0.02
Advertisement
I typecast NULL as NOTHING and then define VOID, NADA, BLANK as NOTHING... just to make it even more confusing for noobs ;)


and btw: real programmers program in 1's and 0's so that they never have to deal with stupid name associations.
visual studio 2005 professional has:

#define NULL (-1)
Quote:Original post by Anonymous Poster
visual studio 2005 professional has:

#define NULL (-1)

In which header? -> Click Me.
It's either a very bad joke or a troll.

From stdlib.h (which is included by cstdlib):
/* Define NULL pointer value */#ifndef NULL#ifdef __cplusplus#define NULL    0#else#define NULL    ((void *)0)#endif#endif
-Mike
Thanks for the enlightenment, dudes! ;)

Looking back, it turns that it wasn't strange at all. I'd say never listen to your lecturer.
When I first started learning C, I guessed NULL was declared/defined in "stdio.h". But NULL was being used just about everywhere, in every book, in every tutorial, whether it was DOS or Windows. So I thought "windows.h" was either including something from the standard libs, or it declares NULL on its own. But I never excluded the possibility that NULL could be "internally declared/defined". Whatever... The thing is that NULL has to be some value, and what would it be if not 0?

Sometime later I get to learn this at university, and the lecturer says: "NULL is not the same as 0". (Or at least I misunderstood). So if it's not the same, than it must be internally declared, so the compiler knows it as a pointer.

And now, for the first time in 4 years I get this "strange" error message. ;) Apparently I REM'ed out the include directive to see if I can kick the error messages regarding the template. Off to download the newer version of VC. Hopefully it doesn't require Windows XP.

Thanks again!
Maybe your lecturer meant the NULL in C and in C it's not necessarily 0 oder (void*)0. The value is implementation defined.
But in c++ 0 and NULL are the same.

This topic is closed to new replies.

Advertisement