-
-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embracing 'nullptr' #6313
base: master
Are you sure you want to change the base?
Embracing 'nullptr' #6313
Conversation
There are a few instances where I've seen NULL being explicitly casted to a different pointer type. Are these still desired? |
I am not sure I understand what you are "resolving" in the sense that we already intently disable the warnings in our code? I'm ok to merge in location where those pragma are not convenient or too noisy (e.g. examples' main.cpp, or in selected places) but I am not sure there is much value doing it everywhere. It's also not possible in the imstb_xxx files which are C code and external librairies. It's probably incorrect in the I'll look into selectively merging some of it. |
So this is a bit embarrassing. Several days ago, I had encountered warnings being generated by the implot library when included with -Wzero-as-null-pointer-constant. However, I later misremembered it as both imgui and implot causing warnings, and went through the effort of purging zero as a null pointer constant in both repositories. You are correct that the warnings are properly suppressed in the imgui headers, though I still believe fixing the warnings is a better approach. Also, sorry for accidentally touching C header files. |
While I was reverting my changes to ImFontAtlas::SetTexID(ImTextureID), I found an example which already ignores your advice, lol. I will still revert it for mine. imgui/backends/imgui_impl_metal.mm Lines 342 to 348 in a7703fe
|
38b20f5
to
4bb3d45
Compare
I have merged 506f7e0 to cover all backends/examples/docs/misc files but not the main codebase. I'm still not at ease with this because:
Aside from those consideration, I must say I genuinely appreciate that your PR is being well done and polished (with consideration for aligned comments). As I general answer to:
I surely can tell that if were to follow any sorts of C++ guidelines from Mr Stroustrup, Dear ImGui wouldn't exist :-) |
I don’t want to overstep on decision at implot but in the meanwhile i would accept one that just disabled the warning like imgui does. Update done on implot. |
Hello. This is a PR born out of another PR of mine which aims to enable more compiler warnings for the Dolphin Emulator project. While hopefully we won't want/need every external library's headers to be warning-free once all platforms support CMake 3.25, I thought why not improve Imgui's compliance to the C++ Core Guidelines. I found hints in the comments of the examples that a switch from 'NULL' to 'nullptr' has already been attempted, though there was clearly more to do.
This PR is split into three commits. Round 1 consists of changes I was able to very quickly verify and fix by compiling an example on my Linux machine with '-Wzero-as-null-pointer-constant' enabled. Round 2 has changes I verified using context clues, online documentation, and by switching to my Windows VM for further info. Finally, I have put the changes to (most) comments and documentation in a seperate commit. I am not familiar enough with Imgui to be sure I updated the documentation correctly, so please tell me if I did not.