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

Change the loop variable to size_t to remove the compilation warning #334

Merged
merged 11 commits into from
May 6, 2024

Conversation

zwu0922
Copy link
Contributor

@zwu0922 zwu0922 commented May 6, 2024

BEGINRELEASENOTES

  • xtalk_neighbors_moduleThetaMergedSegmentation.cpp: change the loop variable itField from int to size_t, in order to remove a compilation warning.

ENDRELEASENOTES

@jmcarcell
Copy link
Member

This is typically done by declaring the loop variable, itField in this case, to be size_t instead of int; it represents better that itField is going to represent a size or count and you don't have to do any casting. Can you change it to size_t and update the release notes above?

@zwu0922 zwu0922 changed the title Cast aFieldNames.size() to remove the compilation warning Change the loop variable to size_t to remove the compilation warning May 6, 2024
@zwu0922
Copy link
Contributor Author

zwu0922 commented May 6, 2024

This is typically done by declaring the loop variable, itField in this case, to be size_t instead of int; it represents better that itField is going to represent a size or count and you don't have to do any casting. Can you change it to size_t and update the release notes above?

The type of itField has been changed to size_t. The title and comment of the PR are modified accordingly.

@BrieucF
Copy link
Contributor

BrieucF commented May 6, 2024

Hi, and with this you do not need to cast itField to int inside the loop?

@zwu0922
Copy link
Contributor Author

zwu0922 commented May 6, 2024

Hi, and with this you do not need to cast itField to int inside the loop?

At least from my observation, size_t works fine without casting inside the loop. I didn't receive any warning during the compilation. And I was able to produce the crosstalk map.

@jmcarcell
Copy link
Member

Hi, and with this you do not need to cast itField to int inside the loop?

No, this is done for you. But with comparisons, signed and unsigned values can be trickier, for example cout << (1U < -2) << endl; prints 1. So that's why the warning appears.

@jmcarcell
Copy link
Member

I think that with clang there are more warnings, but this should remove the two that appear with GCC.

@jmcarcell jmcarcell merged commit ca423a0 into key4hep:main May 6, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants