3 ms·
You can look at headers: #define NULL 0 //C++ #define NULL ((void*)0) //C I think later versions of C++ do something...different, but I’m not up to date enou
by mikestew 7y ago
You can look at headers:
#define NULL 0 //C++
#define NULL ((void*)0) //C
I think later versions of C++ do something...different, but I’m not up to date enough to know without looking it up.
- perl4ever 7y agoOk, I wasn't thinking of C, but even so, isn't NULL a pointer value, not an integer? If you're treating a null pointer as an integer zero, something's gone very wrong. Also I think I vaguely remember from discussions about the standards, that a NULL pointer is not guaranteed to be numerically equal to zero in a standards compliant compiler. But yeah, I was thinking of database NULLs.
- boring_twenties 7y agoC++03 and earlier stipulate that literal 0 is always the null pointer, whether it really is on any given hardware or not. C++11 and later deprecate this and introduce a new keyword `nullptr`. edit: Also, null is not an empty string. The null character that terminates a string is unrelated to null pointers.
- mikestew 7y agoMan, this is one of those discussions I’d like to drag out for a little bit, but unfortunately not in a position to do so. I will leave you with the idea that null can indeed be a value, as in a null-terminated string. Go look at that guy in memory.
- perl4ever 7y agoIf you're going to split hairs, I'm going to say a NUL character is obviously not the same concept as a NULL in general, nor is it a number that you'd use for a coordinate.
- boring_twenties 7y agoThe definition of NULL is technically machine-dependent in C. It happens to be 0 on (almost?) every machine, but that's not guaranteed. In C++ it's guaranteed to be 0.
- simcop2387 7y agoThe times where it wasn't zero are interesting, https://stackoverflow.com/questions/2597142/when-was-the-null-macro-not-0 https://stackoverflow.com/questions/2597142/when-was-the-nul...
- boring_twenties 7y ago"May you live in interesting times!"