Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't #define OPEN and CLOSED #39

Open
tig opened this issue Jun 29, 2021 · 0 comments
Open

Don't #define OPEN and CLOSED #39

tig opened this issue Jun 29, 2021 · 0 comments

Comments

@tig
Copy link

tig commented Jun 29, 2021

In Keypad.h the following macros are defined

#define OPEN LOW
#define CLOSED HIGH

Because of this, any code that includes Keypad.h can't use OPEN or CLOSE for enum names. E.g.

  enum ActuatorStatus
  {
    CLOSED,
    OPEN,
    CLOSING,
    OPENING,
    TIMEOUT,
    ERROR = -1
  };

image

In addition, these #defines are duplicated in Key.h.

Super annoying.

One way to fix this is to delete the #defines from Keypad.h and replace the ones in Key.h with:

#define __OPEN LOW
#define __CLOSED HIGH

or, even better:

enum ButtonState {
   OPEN = LOW,
   CLOSED = HIGH
};

Or something similar.

@tig tig changed the title Don't #define OPEN and COSED Don't #define OPEN and CLOSED Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant