On Wednesday 20 April 2005 14:16, Jerry Feldman wrote:
On Tuesday 19 April 2005 7:39 pm, Philipp Thomas wrote:
That's from the pre-ANSI days, when void and 'void *' didn't exist. The C standard defines NULL to be (void *)0.
Not entirely true: "NULL which expands to an implementation-defined null pointer constant". ISO/IEC 9899:1999
A rather vague definition. I was recently looking at what to do with NULL in C++. So I looked it up in Stroustroup. In section 5.1.1 "Zero" there is the following paragraph: In C, it has been popular to define a macro NULL to represent the zero pointer. Because of C++ tighter type checking, the use of plain 0, rather then and suggested NULL macro leads to fewer problems. If you feel you must use NULL, use "const int NULL = 0;" The const qualifer prevents accidental redefinition of NULL and ensures that NULL can be used where a constant is required. I really don't understand what Bjarne means. Particularly the mention of 'tighter type checking' and 'fewever problems' seem odd. Of course macros are evil so that is a good reason not to use NULL. The ISO C++ standard only refers to NULL in the conext of the <cxxx> header files. -- ___________________________________ Michael Stevens Systems Engineering 34128 Kassel, Germany Navigation Systems, Estimation and Bayesian Filtering http://bayesclasses.sf.net ___________________________________