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

Fix gcc compiler warning in testFun.cpp #262

Merged
merged 3 commits into from
Oct 24, 2022

Conversation

cary-ilm
Copy link
Member

@cary-ilm cary-ilm commented Jun 2, 2022

PR #250 changed the %lx to %llx to suppress an MSVC warning, but it
introduced a gcc warning, where uint64_t is long, not long
long. Better to leave it as %lx and just cast to long. It's only a
printf anyway.

Signed-off-by: Cary Phillips cary@ilm.com

PR AcademySoftwareFoundation#250 changed the %lx to %llx to suppress an MSVC warning, but it
introduced a gcc warning, where uint64_t is long, not long
long. Better to leave it as %lx and just cast to long. It's only a
printf anyway.

Signed-off-by: Cary Phillips <cary@ilm.com>
@cary-ilm
Copy link
Member Author

cary-ilm commented Jun 2, 2022

@fpsunflower, can you confirm that this doesn't re-introduce the MSVC warning you fixed in #250? Turns out that change introduced a gcc warning.

@fpsunflower
Copy link
Contributor

Its probably ok, but I think it would be better to explicitly cast to unsigned long long here since the intent is to inspect the 64bit value in the double. long is 32 bit on windows :(

Signed-off-by: Cary Phillips <cary@ilm.com>
@cary-ilm
Copy link
Member Author

cary-ilm commented Jun 3, 2022

Got it, and it looks like my first take failed on Windows anyway. Thanks.

@kmilos
Copy link

kmilos commented Sep 13, 2022

IMHO it's better to keep using the platform-independent fixed-width types whenever possible, but change the print specifiers to match instead: platform-independent "PRIx64" in this case from inttypes.h

This shoudl properly avoid warnings on all platforms.

Signed-off-by: Cary Phillips <cary@ilm.com>
@cary-ilm cary-ilm merged commit 443b7f0 into AcademySoftwareFoundation:main Oct 24, 2022
cary-ilm added a commit to cary-ilm/Imath that referenced this pull request Oct 31, 2022
* Fix gcc compiler warning in testFun.cpp

PR AcademySoftwareFoundation#250 changed the %lx to %llx to suppress an MSVC warning, but it
introduced a gcc warning, where uint64_t is long, not long
long. Better to leave it as %lx and just cast to long. It's only a
printf anyway.

Signed-off-by: Cary Phillips <cary@ilm.com>

* cast to unsigned long long for %llx

Signed-off-by: Cary Phillips <cary@ilm.com>

* In printf, bit_cast to uint<n>_t and use PRIx<n>

This shoudl properly avoid warnings on all platforms.

Signed-off-by: Cary Phillips <cary@ilm.com>

Signed-off-by: Cary Phillips <cary@ilm.com>
cary-ilm added a commit that referenced this pull request Nov 3, 2022
* Fix gcc compiler warning in testFun.cpp

PR #250 changed the %lx to %llx to suppress an MSVC warning, but it
introduced a gcc warning, where uint64_t is long, not long
long. Better to leave it as %lx and just cast to long. It's only a
printf anyway.

Signed-off-by: Cary Phillips <cary@ilm.com>

* cast to unsigned long long for %llx

Signed-off-by: Cary Phillips <cary@ilm.com>

* In printf, bit_cast to uint<n>_t and use PRIx<n>

This shoudl properly avoid warnings on all platforms.

Signed-off-by: Cary Phillips <cary@ilm.com>

Signed-off-by: Cary Phillips <cary@ilm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants