arduino / ArduinoCore-API

Hardware independent layer of the Arduino cores defining the official API
https://www.arduino.cc/reference/en/
GNU Lesser General Public License v2.1
216 stars 120 forks source link

`bitWrite` macro does not enclose argument in () #153

Closed positron96 closed 3 years ago

positron96 commented 3 years ago

https://github.com/arduino/ArduinoCore-API/blob/173e8eadced2ad32eeb93bcbd5c49f8d6a055ea6/api/Common.h#L68

Current version does not wrap arguments in "()", so it works incorrectly when used like this:

bitWrite(var, bit, cond?1:0);

Some cores probably copied this header, as seen in stm32 and esp32

facchinm commented 3 years ago

Hi @positron96 , thanks for spotting this! would you mind submitting a PR with the fix so we can give the proper attribution?