3 ms·
> NULL is a macro. You're missing the whole point. As per the C standard, NULL is an implementation-defined null Pointer constant. Macros are resolved in the
by roqi 3y ago
> NULL is a macro.
You're missing the whole point.
As per the C standard, NULL is an implementation-defined null Pointer constant.
Macros are resolved in the preprocessing step. The compiler does not know what a macro is. What the compiler knows is whatever the preprocessor passes off in place of the macro. This means the compiler only sees a constant, and has no way to tell what that constant means.
If instead of passing random pointer constants you pass an actual type, now the compiler can tell more things.
> If NULL had been (...)
Irrelevant. The whole point is that it wasn't the committee looked at the problem, and it determined that using a dedicated type is safer, more powerful, and more elegant than passing magic numbers around.
- ori_b 3y agoI am on the committee. As you can probably tell by my posts, this was not unanimous. I'd categorize nullptr as 'mostly harmless'