base empty implementation for non-pure virtual functions in HardwareSerial.h #433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Although the GCC 7-2017Q4 presently bundled into the Arduino SAMD v1.8.3 package doesn't complain, more recent compiler versions are not as accommodating. What I've seeing with GCC 8-2018Q4 is:
Uart.o: in function 'HardwareSerial::HardwareSerial()': undefined reference to 'vtable for HardwareSerial'
The Uart class is derived from HardwareSerial, and the compiler error is due to begin() and end() not being pure virtual and not having a base class implementation.
I see two options. One would be to declare begin() and end() as pure virtual (as everything declared in HardwareSerial is). However, I presume there is some latent reasoning by the author to exclude those particular declarations. If we change this, there also seems to be the possibility of breaking someone's code.
The second option would be to provide a base empty implementation for these functions. This satisfies the compiler's need to have a default implementation should the derived classes not implement one.