Skip to content

LED_BUILTIN must be macro not const int #4134

Closed
@bperrybap

Description

@bperrybap

The symbol LED_BUILTIN is supposed to be a macro not a const int
This was discussed at length on the Arduino developers mailing list years ago and final conclusion is that it must be a macro.
The reason is that some boards have a builtin led and some don't.
The only way for code, particularly library code that runs a many different platforms/core/boards, to "know" if the board that the code is being compiled for has a built in led is to use a macro for LED_BUILTIN so that the code can do compile time conditionals and enable / disable any led code appropriately when being built for various boards.

If you go look at the variants that arduino.cc supplies and even the esp8266 variants, you will see that LED_BUILTIN is a macro rather than a const int

variants that use const int instead of a macro will "trick" code into thinking that there is no built in led.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions