News for hackers. Stuff that matters.
Re:nil, Nil, NULL, NSNull by cjensen on Monday January 07, 2013 @11:24PM (#5024890)
No! C and C++ are define NULL identically: it can be either 0 or (void * ) 0 at the discretion of the compiler author.

So the bug you mention which bit you by using "C library from C++" was not caused by a difference between C and C++. It was caused by a difference in the definition of NULL between those two compilers. You could just as easily have found a C++ compiler which did work, or a C compiler which didn't.

Re:nil, Nil, NULL, NSNull by mpyne on Wednesday January 09, 2013 @10:14AM (#5031867)
If you think a C++ compiler has the option to define NULL as ((void * ) 0) then all I ask is that you simply try it yourself and let me know what compiler error you get. Make sure to turn off permissive flags.

    class Foo { };
    int main() {
        Foo *foo = malloc(sizeof(Foo)); // returns void*
    }
Re:nil, Nil, NULL, NSNull by cjensen on Wednesday January 09, 2013 @03:45PM (#5033400)
You are confusing the preprocessor #define named NULL with the null pointer. Your code example involves void pointers, which is yet a third thing.
Re:nil, Nil, NULL, NSNull by mpyne on Thursday January 10, 2013 @11:16AM (#5037729)
That's because NULL is the pre-processor define. The null pointer itself has no name in C or C++ (pre-11), except that the language will convert integer '0' into whatever the hardware's null pointer is (usually also 0) when converting integral types to pointer types. C++11 added a name and specific type for the null pointer but that's about it.