Skip to content
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

Refactor: replace NULL with nullptr in source code. #7071

Closed
wants to merge 1 commit into from
Closed

Refactor: replace NULL with nullptr in source code. #7071

wants to merge 1 commit into from

Conversation

TerensTare
Copy link

Given the upgrade to C++11, I believe it's appropriate to replace NULL with nullptr, to match the change done to the backends.

This PR replaces all occurrences of NULL with nullptr in the codebase, except the following cases:

  • string literals, namely "NULL" and "" (all found in imgui.cpp) are not changed,
  • stb-related files are left untouched,
  • changelog comments are left untouched,
  • branches other than master are not affected.

Also, I removed usages of #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" as nullptr is a keyword rather than a constant that might be defined as 0.

@ocornut
Copy link
Owner

ocornut commented Nov 28, 2023

Linking to #6313

@ocornut
Copy link
Owner

ocornut commented Nov 28, 2023

In particular see this comment
#6313 (comment)

I've pushed c6ec69c with said changes in backends & examples folders where some were missing.

@TerensTare
Copy link
Author

I see your reasoning to this. In my understanding, the difference between NULL and nullptr is the guarantee that nullptr does not cause ambiguity in overloaded functions, thus the PR does not affect user code in any way. But then again, I believe that's exactly the purpose of this PR (and #6313 as well); to replace code using C features with improved features of C++11 without affecting user-facing code.

The large number of conflicts caused by the change feels to me like the big deal that is blocking this, so how about there exists a separate branch where different C++11 features are integrated into the codebase (on top of my head, I can see scoped enums and move semantics be of benefit). It can serve as some kind of playground to test language features before being integrated into the main branch (hopefully). I am willing to maintain this branch in case it is created.

@ocornut
Copy link
Owner

ocornut commented Dec 1, 2023

In my understanding, the difference between NULL and nullptr is the guarantee that nullptr does not cause ambiguity in overloaded functions,

Yes but none of the changes proposed to imgui.h relates to that. We are changing default arguments here, it will have zero impact to the user. The different between NULL and nullptr would be meaningful in calling/user code, not in imgui code.

The large number of conflicts caused by the change feels to me like the big deal that is blocking this, so how about there exists a separate branch where different C++11 features are integrated into the codebase (on top of my head, I can see scoped enums and move semantics be of benefit). It can serve as some kind of playground to test language features before being integrated into the main branch (hopefully). I am willing to maintain this branch in case it is created.

Conflicts and branch divergence is one main issue and you propose to create another branch? I'm not sure if this is serious or not. I push dozens of commits everyday to public and private branches, not going to rely on someone to maintain some esoteric branch which happens to have zero tangible value to the end user. Scoped enums were evaluated and don't work, they require custom overload for bit manipulation - which we use everywhere - and since C++ is so poor it adds meaningful runtime and debug overhead to debug builds.

@TerensTare
Copy link
Author

I understand. Thank you for everything.

@TerensTare TerensTare closed this Dec 1, 2023
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.

2 participants