Skip to content

DISABLED macro may conflict with sketches #2072

Closed
@ewasscher

Description

@ewasscher

Basic Infos

The macro DISABLED as defined in Arduino.h may conflict with some sketches.

Hardware

Hardware: All ESP8266
Core Version: 2.2.0

Description

The macro DISABLED as defined in Arduino.h may conflict with some sketches when DISABLED is defined in the sketch or library. Changing from a generic name like "DISABLED" to a more specific name like "ESP8266_INT_DISABLED" would help to avoid collisions like this. Would this be an option?

Sketch

#include <Arduino.h>

enum class State : uint8_t {
  DISABLED,
  WAITING,
  READING,
  CHECKSUM,
};

void setup() {

}

void loop() {

}

Debug Messages

Build options changed, rebuilding all
In file included from /tmp/arduino_modified_sketch_437587/sketch_may30b.ino:1:0:
/home/ewasscher/.arduino15/packages/esp8266/hardware/esp8266/2.2.0/cores/esp8266/Arduino.h:76:19: error: expected identifier before numeric constant
 #define DISABLED  0x00
                   ^
/tmp/arduino_modified_sketch_437587/sketch_may30b.ino:4:3: note: in expansion of macro 'DISABLED'
   DISABLED,
   ^
/home/ewasscher/.arduino15/packages/esp8266/hardware/esp8266/2.2.0/cores/esp8266/Arduino.h:76:19: error: expected '}' before numeric constant
 #define DISABLED  0x00
                   ^
/tmp/arduino_modified_sketch_437587/sketch_may30b.ino:4:3: note: in expansion of macro 'DISABLED'
   DISABLED,
   ^
/home/ewasscher/.arduino15/packages/esp8266/hardware/esp8266/2.2.0/cores/esp8266/Arduino.h:76:19: error: expected unqualified-id before numeric constant
 #define DISABLED  0x00
                   ^
/tmp/arduino_modified_sketch_437587/sketch_may30b.ino:4:3: note: in expansion of macro 'DISABLED'
   DISABLED,
   ^
sketch_may30b:8: error: expected declaration before '}' token
 };
 ^
exit status 1
expected declaration before '}' token

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions