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

Compiler warning #10

Closed
aikopras opened this issue Jan 4, 2022 · 2 comments
Closed

Compiler warning #10

aikopras opened this issue Jan 4, 2022 · 2 comments

Comments

@aikopras
Copy link

aikopras commented Jan 4, 2022

Hallo Franz-Peter

While compiling with all warnings on, I get the following compiler warning:

... MoToServo.cpp:314:14: note: in expansion of macro 'constrain'
... warning: comparison between signed and unsigned integer expressions

As far as I know, the cause is that the compiler selects an unsigned type for MINPULSEWIDTH and MAXPULSEWIDTH, whereas the type of _minPw and _maxPw is uint16_t.
The warning can easily be avoided by adding the uint16_t to the #defines in MobaTools.h.
For example (for the AVR and STM32 case):

#define MINPULSEWIDTH   700     // don't make it shorter than 700
#define MAXPULSEWIDTH   2300    // don't make it longer than 2300

should be changed into:

#define MINPULSEWIDTH   ((uint16_t)700)     // don't make it shorter than 700
#define MAXPULSEWIDTH   ((uint16_t)2300)    // don't make it longer than 2300

I know this is a minor thing, but I always try to avoid red lines in the compiler output ;-)

@MicroBahner
Copy link
Owner

MicroBahner commented Jan 6, 2022

Hi Aiko,
how did you manage to get this warning? I always compile with all warnings on, but I did not get this warning.

Franz-Peter

#Edit: got it! I had to use the mightyCore to get the warning. It will be fixed in the next release. It is sufficent to append an 'U' to the number:

#define MINPULSEWIDTH   700U      // don't make it shorter than 700
#define MAXPULSEWIDTH   2300U     // don't make it longer than 2300

@MicroBahner
Copy link
Owner

Fixed in release 2.4.3

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

No branches or pull requests

2 participants