-
Notifications
You must be signed in to change notification settings - Fork 7.6k
bitWrite macro does not enclose argument in () #4466
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
Comments
Please submit a PR. You can do so right on that page by clicking the edit (pencil) icon. |
Huh, didn't know it was that easy. |
Well, you got the fork part done. It should have had some option in there to create the pull request. If you go to the main repo page now, you should see a message at the very top showing that you have an edit ready for a pull request. Click on that button and it should take you to the PR page. Enter |
Current version does not wrap arguments in "()", so works incorrectly when used like this: ``` bitWrite(var, bit, cond?1:0); ``` Same as in here: espressif/arduino-esp32#4466
Hello.
I've found a trivial bug in
bitWrite
macro. It's written as#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
and its argument bitvalue is not enclosed in parentheses. This gives incorrect result for some arguments, for example I've triggered the bug with this code:The macro is here: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Arduino.h#L91 and it affects all versions of ESP32 core since it was introduced.
In AVR Arduino core this macro is correct:
https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/Arduino.h#L115
The text was updated successfully, but these errors were encountered: