Skip to content

Conversation

bibo38
Copy link

@bibo38 bibo38 commented Dec 9, 2017

Since Clang 5, it can warn about the usage of 0/NULL instead of nullptr. This caused me to include some ugly workaround in the Cuberite project.

To fix this problem at the root, I've used CMake to generate an appropriate includefile, which checks if nullptr is supported. Based on this check the macro COMPABILITY_NULLPTR is either set to nullptr or 0.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.344% when pulling 62347c2 on bibo38:fix_nullptr into 3f3b174 on SRombauts:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.344% when pulling 2a0d13d on bibo38:fix_nullptr into 3f3b174 on SRombauts:master.

@bibo38
Copy link
Author

bibo38 commented Dec 9, 2017

Since CMake 3.2 defined the macro as static_cast<void*>(0) and didn't recognized the Apple Clang compiler, I've just added the generated file with CMake 3.9 to the project.

The alternative would be to require at least CMake 3.8. This version adds a flag to prevent erros, if the compiler cannot be detected.

P.S.: Travis failed due some apt-get problem...

@SRombauts
Copy link
Owner

Hi @bibo38, thank you very much for the time you took to propose this!

I was hesitant to use such a (quite complexe) CMake solution...

So I was about to simply use "nullptr" and drop support for older compilers, but I decided to rely instead on one of my old "Utils.h" file from my SRombauts/LoggerCpp projet.
This Utils.h redefine nullptr_t if possible, or rely on the older NULL macro on older MSVC.

See commit 4f32da1

Cheesr!

@SRombauts SRombauts closed this Dec 13, 2017
@SRombauts SRombauts self-assigned this Dec 13, 2017
@bibo38 bibo38 deleted the fix_nullptr branch December 14, 2017 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants