3 ms·
All hail the bloat-lords. PS. Why are the additions of nullptr, and strongly typed enums a good thing? and doesn't C++ already have a NULL from C?
by newt0311 18y ago
All hail the bloat-lords.
PS. Why are the additions of nullptr, and strongly typed enums a good thing? and doesn't C++ already have a NULL from C?
- KirinDave 18y agoC's NULL sucks, because it's not a unique value and thus can be "lost" or confused with other values. Having a distinct null which can only be arrived at by typing the characters "null" is a good thing, imo.
- tptacek 18y agoCan you tell a story about how NULL bit you in the ass in real code?
- qwph 18y agoI remember one early version of a C++ compiler which had NULL #defined as (( void* )0), which caused all manner of fun trying to compile some legacy C code. This was in 1999, I think.
- tptacek 18y agoYou mean like this? #define NULL __DARWIN_NULL ... #define __DARWIN_NULL ((void *)0)
- qwph 18y agoSomething like that. It makes the following invalid in C++ but valid in C: int *ptr = NULL;
- bdash 18y agoExcept for the fact that the real definition is actually more like: #ifdef __cplusplus #define __DARWIN_NULL __null #else /* ! __cplusplus */ #define __DARWIN_NULL ((void *)0) #endif /* __cplusplus */ So the code you mentioned works just fine in C++.
- qwph 18y agoExcept that the actual compiler I was using was for the PlayStation 2, so I very much doubt it had that precise code you just outlined, and it really did have NULL defined as ((void* )0), and it really did break. I saw it happen.
- newt0311 18y agoIsn't the right solution to make C NULLs a unique value or at least get rid of them now that a better replacement is here. Seriously, have 5 different ways of doing the same thing is how perl became a hell hole for anything more than 10 lines.