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

warning: comparison of integer expressions of different signedness #209

Open
kinlougha opened this issue May 13, 2024 · 7 comments
Open
Labels
bug pending pending the next release

Comments

@kinlougha
Copy link

Describe the bug
Receive this warning when compile OnStepX under VSCode:

In file included from .pio\libdeps\teensy41\RTC\src\RtcDateTime.cpp:29:
.pio\libdeps\teensy41\RTC\src\RtcDateTime.h: In member function 'RtcDateTime RtcDateTime::operator+(int32_t) const':
.pio\libdeps\teensy41\RTC\src\RtcDateTime.h:168:41: warning: comparison of integer expressions of different signedness: 'int32_t' {aka 'long int'} and 'uint32_t' {aka 'long unsigned int'} [-Wsign-compare]
168 | if (seconds < 0 && abs(seconds) > totalSeconds)

**Development environment

  • OS: Window11
  • Build Environment VSCode v1.89.0
  • Board target Teensy 4.1
  • Library version 2.4.2

Correction: Change "int32_t" for "uint32_t" on line 164 of RtcDateTime.h

Thanks.

@Makuna
Copy link
Owner

Makuna commented May 13, 2024

That is not a correct fix. This is to support the ability for a statement like

int32_t offset = -60; // one hour back, may latter be changed to forward time
//blah blah
time += offset;

the abs() will need to be cast since it seems the platform you are using doesn't have a unsigned abs(signed) version for the compiler to select.

@Makuna Makuna added the bug label May 13, 2024
@kinlougha
Copy link
Author

OK I understand, i open a case to PJRC with this info and close this case.

Thanks.

@kinlougha
Copy link
Author

Hello,

This is the answer from PJRC : https://forum.pjrc.com/index.php?threads/warning-message-at-compile.75017/

@Makuna
Copy link
Owner

Makuna commented May 14, 2024

#210

@Makuna Makuna reopened this May 14, 2024
@Makuna Makuna added the pending pending the next release label May 14, 2024
@kinlougha
Copy link
Author

Hi Michael,

I test the solution, with the master branch, on 2 platforms (Teensy 4.1 and ESP32) and no more warning from the library.

This case is close for me.

Thanks.

@Makuna Makuna reopened this May 14, 2024
@Makuna
Copy link
Owner

Makuna commented May 14, 2024

Leave it open (its marked as Pending). I will close it when I publish the next update.

@kinlougha
Copy link
Author

Sorry Michael, I leave it open, I understand.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pending pending the next release
Projects
None yet
Development

No branches or pull requests

2 participants