-
Notifications
You must be signed in to change notification settings - Fork 2k
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
macros/utils: add LIMIT() and ABS() macros #20352
Conversation
Looks like there is a name collision with a macro defined in a esp32 package. I am open to other names for the new macro. |
If you use the same definition as ESP32, would it still be a redefinition? 🤔 |
I tested the following and did not get an error or warning: #define FOO 1
#define FOO 1 I don't know if that is promised by the language or just allowed by gcc. Do you know off the top of your head before I go looking? It does feel a bit precarious thought to rely on matching a macro defined outside the source tree. I though about moving it to macros/math.h and calling it |
If it works on CI you can be sure that all supported compilers are covered. |
Ok, I made the change. Also I added the classic |
Please squash! |
This patch adds a macro that can be used to limit a value to a given range.
This patch adds the classic ABS() macro to exist along side of the MAX/MIN macros.
4fda373
to
45c1441
Compare
squashed |
Please wait to merge. I will added unit tests for these macros. |
Ok, unit tests are added now for new and some existing macros. |
Contribution description
This patch adds a macro that can be used to limit a value to a given range. It also adds the classic
ABS()
macro to go along with the existingMAX()
andMIN()
macros.Testing procedure
It's fairly trivial. I have used it and it works in my application code.
Issues/PRs references