why does cocos2dx convert int to long in many classes?

I hope I won’t face your software and code.

if you can remove the warning, why don’t do that?

ning li:

So keep it simple, and let the warning just show.

Thanks, but as I said, we want to fix all the warnings.
If you have a better way to fix them, let us know.
But for us, leaving the warnings unfixed is not an option.
thanks.

Why not just skip int/unsigned int and go for
uint8_t
uint16_t
uint32_t
uint64_t
int8_t
int16_t
int32_t
int64_t

int might be the fastest type in the calculation, but reading memory is slow. I guess it might be faster, depending on the HW of cause, to add 8 int8_t instead of eight int64_t (if you know that the the result will not overflow). It all depends on the use case, so why not specify the appropriate size instead of just stating int?

In my book int shall be avoided.

Fredrik:

Thanks. When we need a type of a certain size, we should use those types.
https://github.com/cocos2d/cocos2d-x/blob/develop/docs/CODING_STYLE.md#integer-types

Ah, I didn’t know that you were using such a good coding standard. Excellent Riq!

I have send a pull request to change long to size_t in Array: https://github.com/cocos2d/cocos2d-x/pull/4416. I will send more pull request for this issue.

minggo: great. thanks.

New pull request for this issue https://github.com/cocos2d/cocos2d-x/pull/4429.

thanks Minggo.

I added a few comments to the PR, but only minor issues.
I think the PR is ready to be merged. Thanks!

Ricardo Quesada wrote:

What about this ?
>
* the API definition (parameters and returns values) should never use auto
* local variables could use auto… it is not mandatory, but auto is allowed to be used in local variables
* if a size is expected in a API like int get_size(), size_t (or std::size_t) should be used instead of int.
* int or long should be used when it makes sense: by default int should used. But if the compiler is raising “implicit conversion to 32-bit type”-warning, and it is not a size, long should be used instead.
* If the API is expecting a 64-bit type (either in32-bit or 64-bit mode), it should use uint64_t or int64_t
>
thoughts ?

I think that we should give top priority to use explicit type in local variables.
Only in the case of vague type,we should use auto
for example:

template 
void Multiply(T t, U u) {
  auto v = t * u;
}

thoughts?