Skip to content

Added #define LED_BUILTIN to all pins_arduino.h that need it. #4518

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

Closed
wants to merge 1 commit into from
Closed

Added #define LED_BUILTIN to all pins_arduino.h that need it. #4518

wants to merge 1 commit into from

Conversation

lbernstone
Copy link
Contributor

Fixes #4134

#define BUILTIN_LED2 LED_BUILTINB
#define LED_BUILTIN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LED_BUILTINB?

@me-no-dev
Copy link
Member

how does a define and a const char coexist?

static const uint8_t LED_BUILTIN = 4;
#define LED_BUILTIN

@@ -13,6 +13,7 @@

static const uint8_t LED_BUILTIN = -1;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and other cases should be #define LED_BUILTIN LED_BUILTIN

@atanisoft
Copy link
Collaborator

how does a define and a const char coexist?

static const uint8_t LED_BUILTIN = 4;
#define LED_BUILTIN

The #define variant is used by the pre-processor and the other by the compiler during code generation. The pre-processor can not see static const variables unfortunately (even static constexpr ... would be invisible)

@me-no-dev
Copy link
Member

this works:

static const uint8_t LED_BUILTIN = 4;
#define LED_BUILTIN LED_BUILTIN

int main(){
#ifdef LED_BUILTIN
	printf("LED_BUILTIN: %u\n", LED_BUILTIN);
#endif
    return 0;
}

@atanisoft
Copy link
Collaborator

Yes, but this won't:

static const uint8_t LED_BUILTIN = 4;

int main(){
#ifdef LED_BUILTIN
	printf("LED_BUILTIN: %u\n", LED_BUILTIN);
#endif
    return 0;
}

The ifdef block will be excluded from compilation.

@me-no-dev
Copy link
Member

yes yes :) i got the problem. PR needs fixing :) likle find and replace 😄

@atanisoft
Copy link
Collaborator

Can you back out this commit so I can submit a PR to fix it?

This PR hasn't been merged yet and is still pending here for fixes.

@lbernstone
Copy link
Contributor Author

No good deed goes unpunished.

@lbernstone lbernstone closed this Nov 10, 2020
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

Successfully merging this pull request may close these issues.

LED_BUILTIN must be macro not const int
3 participants