godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.1k stars 69 forks source link

`int PoolVector<T>::size() const` should return `unsigned int` #1621

Open JUNZ1 opened 3 years ago

JUNZ1 commented 3 years ago

Describe the project you are working on: Creating CPP Module for a Machine Learning Module

Describe the problem or limitation you are having in your project: I face compilation warning(s) because of comparing it with unsigned int value

Describe the feature / enhancement and how it helps to overcome the problem or limitation: There will be no more warning :)

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: By changing the return argument of the interface

If this enhancement will not be used often, can it be worked around with a few lines of script?: No

Is there a reason why this should be core and not an add-on in the asset library?: All the size values should be unsigned int for better logical comparison

Zylann commented 3 years ago

If this enhancement will not be used often, can it be worked around with a few lines of script?: No

Come on, it can xD you can cast it.

Is there a reason why this should be core and not an add-on in the asset library?: All the size values should be unsigned int for better logical comparison

If this is the actual request then that should be done inside Godot because all containers there use int, not even size_t.

Xrayez commented 3 years ago

I face compilation warning(s) because of comparing it with unsigned int value

There will be no more warning :)

You can use various warning build options like werror=no and warnings=no while compiling Godot.

If that doesn't work, this proposal might as well be qualified as a bug report.

JUNZ1 commented 3 years ago

I dont think "muting all warning" is the solution for this problem.. any developer should keep them on not to miss any probable future problem..

Zylann commented 3 years ago

Do you use GCC? I use unsigned ints in a custom Godot module and while MSVC never complained for years with me, when I started setting up a CI with GCC, it started warning about every single bit of mix between int and unsigned int, which prevents the CI from suceeding the compilation since warning as error is used. At first it sounds like "oh, thats a bad use anyway, the developer should fix it" but even though I'm doing my best, it's surprising how often this can happen and how annoying this can be when MSVC doesnt warn about it the same way GCC does:

At least I start to understand why Godot prefers int generally in places where negatives would not be expected :p

JUNZ1 commented 3 years ago

Yes I use GCC, if you ask me these warnings just fork fine, they do their job :D, problem is warnings can not create issues themself :), some one has to create issue about them :)