Sign in to follow this  
Zido_Z

Null is undefined.

Recommended Posts

Zido_Z    360
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 this post


Link to post
Share on other sites
Hodgman    51234
NULL is not a feature of C++.

Many libraries (including Windows), often include the code:[code]#ifndef NULL
#define NULL 0
#endif[/code]
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 this post


Link to post
Share on other sites
alvaro    21246
I prefer to use 0 instead of NULL because I don't like macros. I seem to be in [url="http://www2.research.att.com/~bs/bs_faq2.html#null"]good company[/url].

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this