# Null is undefined.

This topic is 2566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
Yes, I'm an idiot. Forgot my header file. My mistake guys. lol

##### Share on other sites

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

Thank you!

##### Share on other sites
I prefer to use 0 instead of NULL because I don't like macros. I seem to be in good company.

##### Share on other sites
VC 2010 also supports the new C++0x [color="#0000FF"]nullptr keyword, which is a type-safe version of NULL or 0.

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631777
• Total Posts
3002307
×