esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
15.9k stars 13.35k forks source link

macro attributes should be used with brackets #2617

Closed bitluni closed 5 years ago

bitluni commented 7 years ago

Low-level macros are vulnerable to operator priorities which can cause problems. Took me some time to find why my code didn't work

Arduino/tools/sdk/include/eagle_soc.h rows:

# define GPIO_REG_READ(reg)                         READ_PERI_REG(PERIPHS_GPIO_BASEADDR + reg)
# define GPIO_REG_WRITE(reg, val)                 WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + reg, val)

should bechanged to:

# define GPIO_REG_READ(reg)                         READ_PERI_REG(PERIPHS_GPIO_BASEADDR + (reg))
# define GPIO_REG_WRITE(reg, val)                 WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + (reg), val)
devyte commented 6 years ago

@bitluni I still see this in the latest code. Care to make a PR?

devyte commented 5 years ago

Correcting milestone to 2.4.2