Skip to content
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

Fixed shadowing of write(const unint_8_t*, sizte_t) in USBKeyboard #1372



Copy link

commented Aug 20, 2017


The USBKeyboard class inherits from Print and reimplements virtual function write(uint8_t ch).
It does not re-implement write(const uint8_t *buffer, size_t size).

This results in a compiler warning about the second function being shadowed:

In file included from ../wiring/inc/spark_wiring_string.h:34:0,
                 from ../wiring/inc/spark_wiring_stream.h:30,
                 from ../wiring/inc/spark_wiring.h:38,
                 from ./inc/application.h:40,
                 from /home/elco/repos/firmware/platform/spark/modules/Platform.h:4,
                 from /home/elco/repos/firmware/lib/src/DS2408.cpp:8:
../wiring/inc/spark_wiring_print.h:67:20: warning: 'virtual size_t Print::write(const uint8_t*, size_t)' was hidden [-Woverloaded-virtual]
     virtual size_t write(const uint8_t *buffer, size_t size);
In file included from ./inc/application.h:51:0,
                 from /home/elco/repos/firmware/platform/spark/modules/Platform.h:4,
                 from /home/elco/repos/firmware/lib/src/DS2408.cpp:8:
../wiring/inc/spark_wiring_usbkeyboard.h:53:20: warning:   by 'virtual size_t USBKeyboard::write(uint8_t)' [-Woverloaded-virtual]
     virtual size_t write(uint8_t ch);


Include both functions signatures and just delegate to Print:

    virtual size_t write(uint8_t ch);
    virtual size_t write(const uint8_t *buffer, size_t size){
        return Print::write(buffer, size);

Or even simpler:

    using Print::write;
    virtual size_t write(uint8_t ch);

The file was a mix of spaces and tabs. I converted all tabs to 4 spaces.
I am not using the USBKeyboard class. I just want to get rid of the many compiler warnings.
I should probably just write a custom application.h file.


  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to after merging (add links to docs and issues)

@technobly technobly requested a review from avtolstoy Aug 23, 2017

@avtolstoy avtolstoy added this to the 0.7.0 milestone Oct 10, 2017


This comment has been minimized.

Copy link
Contributor Author

commented Dec 20, 2017

This was not merged in RC.6. Just a quick reminder that it is still there.

@m-mcgowan m-mcgowan modified the milestones: 0.7.0, 0.7.0-rc.7 Jan 30, 2018

@m-mcgowan m-mcgowan merged commit 2e0e197 into particle-iot:develop Jan 31, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.

Copy link

commented Jan 31, 2018

This has been cherry-picked into the 0.7.0-rc.7 branch.

@sergeuz sergeuz added the enhancement label Feb 2, 2018

@m-mcgowan m-mcgowan added bug and removed enhancement labels Feb 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.