Null is undefined.

Started by
5 comments, last by Rattrap 12 years, 9 months ago
I'm confused. Visual Studio is flagging the NULL word as undefined. I thought NULL was a system constant for C++. Did something change or is there a replacement for NULL? I cannot even check if a variable is null in an if condition.
Advertisement
NULL is not a feature of C++.

Many libraries (including Windows), often include the code:#ifndef NULL
#define NULL 0
#endif

Depending on which headers you've included, NULL may or may not be defined as 0. If you want to use NULL (and not just use 0), but you haven't included one of these headers in your CPP file, you can just use the above code to define it yourself.
Yes, I'm an idiot. Forgot my header file. My mistake guys. lol
Please do not mark threads "solved" in this forum.

Prior to posting again, please be sure to read the forum rules and abide by them.


Thank you!

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

My bad.
I prefer to use 0 instead of NULL because I don't like macros. I seem to be in good company.
VC 2010 also supports the new C++0x [color="#0000FF"]nullptr keyword, which is a type-safe version of NULL or 0.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

This topic is closed to new replies.

Advertisement