lancaster-university / codal-microbit-v2

CODAL target for the micro:bit v2.x series of devices
MIT License
41 stars 50 forks source link

Overloaded virtual warnings #414

Open dpgeorge opened 3 months ago

dpgeorge commented 3 months ago

When building MicroPython for the micro:bit v2, with CODAL at 0.2.66 and arm-none-eabi-gcc at 13.2.0, I see a lot of warnings about overloaded virtual functions in CODAL.

For example:

In file included from microbit/v2/mpcodal/lib/codal/libraries/codal-core/./inc/driver-models/Compass.h:29,
                 from microbit/v2/mpcodal/lib/codal/libraries/codal-core/source/driver-models/Compass.cpp:25:
microbit/v2/mpcodal/lib/codal/libraries/codal-core/./inc/core/CodalComponent.h:201:21: warning: 'virtual int codal::CodalComponent::init()' was hidden [-Woverloaded-virtual=]
  201 |         virtual int init() { return DEVICE_NOT_SUPPORTED; }
      |                     ^~~~
microbit/v2/mpcodal/lib/codal/libraries/codal-core/./inc/driver-models/Compass.h:300:14: note:   by 'void codal::Compass::init(uint16_t)'
  300 |         void init(uint16_t id);
      |              ^~~~

The init in CodalCompenent is public and virtual, but the init in Compass is private and not virtual. That's probably not a source of any bugs, but IMO this warning should be fixed because it's not clear what behaviour is intended with this init method.

There's a similar issue with codal::TouchSensor::onSampleEvent and codal::NRF52TouchSensor::onSampleEvent.

A few hundred of these warnings go by doing a clean build (because these headers are included in many source files), and that makes it hard to spot other warnings which may indicate actual bugs.

It would be great if these warnings could be removed, ideally by adjusting the code, eg renaming the private init to something else like initInternal.