-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Fix ambiguous for TwoWire::requestFrom() methods and align API with Arduino.cc #8817
Fix ambiguous for TwoWire::requestFrom() methods and align API with Arduino.cc #8817
Conversation
This is an error, not a warning: |
Inside the function, this overload truncated the data type to a shorter one. This could break some users' hopes.
I believe that additional method overloads are not the best solution for disambiguating overload resolution. I believe that requests #5764 and #5768 are erroneous. -- That requests are not solve issue arduino-libraries/ArduinoECCX08#25 |
Thanks for the PR, same here please sign CLA. |
Oh yes. I didn’t understand at first that this needed to be done. |
- implement proposal espressif#8818 (comment) to bring the HARDWARE interface into compliance
👋 Hello safocl, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
@safocl Please fix the CI errors |
Remove non-void values of the return-statements in function returning 'void'.
TwoWire::begin(uint8_t address) should be available without slave support by SoC?
I made commits. |
Compiler reports "Wire.cpp:393:15: error: variable 'err' set but not used [-Werror=unused-but-set-variable]".
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 don't think we should remove the error checking from the function return. It is a good way to check if everything inside the method was correctly checked.
The aim of this PR is fixing the ambiguity of the requestFrom
methods. I think it is fine to create a HardwareI2C
class here but removing the return values should be done in another PR so it can be discussed.
TwoWire::endTransmission() was accidentally deleted from a cpp file.
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.
After discussing with the team we agreed that it is better to keep the return types in the abstract class and the implementation even if differ from the Arduino.cc API.
Do I need to return the return types as they were originally and change them in the abstract class itself? |
Yes. change |
In TwoWire class return return types.
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.
@safocl PTAL
Co-authored-by: Jan Procházka <[email protected]>
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.
Just small formatting fixes, else looks good.
Tested i2c with OLED, works fine.
Co-authored-by: Jan Procházka <[email protected]>
Co-authored-by: Jan Procházka <[email protected]>
Co-authored-by: Jan Procházka <[email protected]>
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.
Thanks @safocl, great job!
Description of Change
Remove (comment out) the TwoWire::requestFrom() method overloads.
The compiler says "warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second"
Tests scenarios
Example 1
Example 2
Example 3
All compilers report this warning.
Related links
C++17 standard says ([over.match.best]):
There is no viable override for these methods that is better - any overrides require equal conversions of different arguments.
upd: this pull request now reflects the accumulated changes for all errors and warnings about ambiguous TwoWire method overloads. It was decided to make a HardwareI2C interface from Arduino.