8000 macro attributes should be used with brackets · Issue #2617 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content
macro attributes should be used with brackets #2617
Closed
@bitluni

Description

@bitluni

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0