-
Notifications
You must be signed in to change notification settings - Fork 3k
Update template argument names to not collide with Arduino names #11504
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
Conversation
@kyle-cypress, thank you for your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not completely certain this is way to go. What is the use of #define A1 P10_0
?
If you need a macro magic world, you can do in pinname header file:
A1 = CYPRESS_ARDUINO_A1
CYPRESS_ARDUINO_A1
can be a macro to get a proper pinout. That way you won't have any conflicts.
I would not expect having A1 as macro - very short, not enough descriptive - leads to problems like this one
I think my counter-suggestion to the issue is "don't do that then". I guess this is a reason why But anyway, it appears as long as There's certainly no need to add any parentheses to
If you are an Arduino form-factor board ( |
Yep, it should be PinNames. Means this PR should not be needed. |
Further than that, an alternative corrective PR to make those defines into enums doesn't seem to be that urgent, as the boards in question have been getting away with the define for a while - it's breaking down if the define is changed to |
The motivation for having the A1 etc aliases as #defines is that it makes for a cleaner target architecture:
This avoids duplication between boards which use the same underlying MCU. The macro-aliasing approach seemed the cleanest way to achieve this, at least until we encountered this issue. If what we're doing is not common/expected/supported, we can pursue alternative approaches (as a side note: if it's not there already, can the porting guide add a note about this usage being unsupported?). For reference, here are some of the options we considered and rejected. I make no claim that this is an exhaustive list of all possibilities; we thought the macro approach was suitable and did not continue evaluating.
|
Can I suggest the opposite?
|
This is similar to what I had on my mind ^^ we should be able to go with one-way inclusion. |
@kyle-cypress Any update? |
We discussed the suggestion to invert the inclusion order and it seems like it would still create a dependency from the Chip support (CSP) on the Board support (BSP). |
@kyle-cypress Please reopen once updated. I'll close this for the meantime as it's not progressed for a month. |
Description
Several templated classes use "A1", "A2", etc as type argument names, which are the same as what mbed requires for Arduino header pin names, which can lead to naming conflicts when board targets define these names as macros.
We noticed this issue because the Cypress board-specific targets provide a header with macros which map arduino pin names to elements in a chip-specific enum. E.g.
If parentheses are added around the macro value (per best practice), compilation fails with various, highly verbose errors related to the FunctionPointer template. Without the parentheses (what is in mbed today) the build succeeds, presumably because the #defines simply act as a still-valid rename of the template parameters.
Pull request type
Reviewers
Release Notes