Does this happen? I thought the committee was so into backwards-compatibility that C++ will also work on everything forever.
Does this happen? I thought the committee was so into backwards-compatibility that C++ will also work on everything forever.
Then one day, you recompile it and no, it /needs/ to be ZERO and not NULL sorry.
But it's just one simple to fix example, in plenty of cases, especially as templates (and especially template instantiations) evolved, the whole thing would come crashing on you. For a while trying to compile templated code on MS, CodeWarrior and GCC was pretty much impossible without deploying ruses that made C preprocessor macros tame in comparison.
Judging by your mention of CodeWarrior, this all sounds like war stories from pre-standardization days (and of course it still took a while after ISO C++98 was published, for implementations to actually adopt it).
True, but is was guaranteed that NULL expands to “an implementation-defined C++ null pointer constant” (C++98 §18.1), where a ‘null pointer constant’ is “an integral constant expression (5.19) rvalue of integer type that evaluates to zero" (C++98 §4.10). So while it didn't have to be just plain (literal) 0, it did have to be a compile-time constant integer 0, which is otherwise just as good unless you're doing macro magic.
(This differed from C (ANSI era), in which a null pointer constant can alternatively have type (void*), and often does.)
The fact that a pure declaration requires a literal single character ‘0’ (rather than 0) is just one sad example of C++'s ad-hoc irregular overloading of things to mean different things.