-
-
Notifications
You must be signed in to change notification settings - Fork 580
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
Fix some sign comparison warnings #1005
Conversation
This code should ideally be kept in sync with It doesn't raise a warning in Godot so I'm curious about what the difference is. When we do need to cast, we prefer C-style casts ( |
Upstream godot uses Maybe it can be changed since we do have |
Ah. I looked at the style guide and did a search on the code base before I used I know it's a PIA, but all these code style "preferences" should probably be in the style guide if they are going to be enforced. It's hard to get a handle on what's "allowed" and what isn't (even looking at the source to try to maintain consistency). |
Well, this seems non trivial, so probably better left to a separate PR in case. |
That's fair, but it's not necessarily always well defined and thus easy to document. As you saw in the codebase |
After 30ish years of C++ that's not going to happen for me - it will always feel unnatural. 😆 |
49d3cd4
to
e6b636c
Compare
Eheh, I think that is kinda the point of these conventions, you don't need 30 years of C++ experience to understand the godot codebase, which used to be slightly more than C with classes. I like to believe that this is part of the reasons why godot has so many contributors unlike other big projects, i.e. that the average C or C++ course is enough to get you started understanding the codebase (at least, it worked for me when I started contributing in 2016 only knowing plain academic C). I have to admit though, that not relying on C++ specific features seems to consistently make C++ veterans unhappy. |
Oh no! Don't get me wrong. I'm not a "use all the features" guy. I'm absolutely a "C with classes" guy. Templates and multiple inheritance are the devil's work. I think C++ has gotten way out of hand in its complexity (I enjoy In this specific case though I would argue that telling new devs to "always use static_cast" is easier/clearer than "use it sometimes, but not others". I'm all about simplicity, consistency, and using the basics of the language properly. e.g. the previous "= default" discussion. It's not complicated to understand and makes the intent immediately obvious. Another one is using Generally I think static analysis tools provide a decent set of guidelines (e.g. clang-tidy's "modernize", "readability", etc.) to cover the basics. Edit:
But they aren't written anywhere, so how do people learn them? The static_cast one is a good example. Maybe someone new to C++ will learn it naturally from the code base, but anyone with any experience at all needs some guidance on the expectations. Last Thought 😄 - this is why something like clang-tidy is awesome. It standardize all this - even if you can't get quite what you want, it's close enough. Kind of like clang-format. |
That for example, comes from the times when some C++ compiler didn't properly support the That said your experience with modernization and consistency tools with "simplified C++" is welcome and it could be really beneficial to the project. We have an old discussion on 4.0 code base modernization ( godotengine/godot#33027 ), I think we could do something similar for |
Thanks! |
Part of #999