4 ms·
Don't use "NULL" in C++[1]. [1] https://cpp4arduino.com/2018/10/26/why-cpp-programmers-dont-use-null.html https://cpp4arduino.com/2018/10/26/why-cpp-programmer
by mhogomchungu 5y ago
Don't use "NULL" in C++[1].
[1] https://cpp4arduino.com/2018/10/26/why-cpp-programmers-dont-use-null.html https://cpp4arduino.com/2018/10/26/why-cpp-programmers-dont-...
- dataflow 5y agoEh. It's fine in my experience... of all the things I've gotten bitten by in C++, this has not been one of them. It's actually a bit more readable IMO... nullptr doesn't scream "null" like it should. And it's best not to overload int with pointers anyway, because other people using your code may still use NULL even if you personally don't. The one thing to watch out for is usage in template call sites, where you'd want to cast it to the correct type first, but at that point you'd want to cast the nullptr too.
- imron 5y agoFrom the article: > Are there any drawbacks to using nullptr instead of NULL? No, unless you target old compilers that don’t support C++11, which is very unlikely. and OP is specifically targeting c++98.
- gpderetta 5y agoWhat else then? In c++11 you would of course use nullptr_t, but the OP code is pre-c++11. GCC used to use a magic builtin in pre C++11 to implement NULL, but IIRC they removed it as non-conforming.
- deleted 5y ago[deleted]