From d3ea88e8c7ba53bf130034e118dc8d4585e157e6 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 17 May 2013 15:57:39 +0200 Subject: [PATCH] AP_HAL: resolved -Woverloaded-virtual warning the function: virtual size_t AP_HAL::Print::write(const uint8_t *buffer, size_t size); was hidden in all derived classes by their virtual size_t write(uint8_t) = 0; implementations. To solve this, a non-virtual write(const uint8_t *, size_t) that calls a virtual write_implementation was added. This isn't necessary atm, because the derived classes don't call write(const uint8_t *, size_t), BUT this decreases the apm2-quad Program size by 40 bytes :D and removes warnings. --- libraries/AP_HAL/utility/Print.cpp | 2 +- libraries/AP_HAL/utility/Print.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL/utility/Print.cpp b/libraries/AP_HAL/utility/Print.cpp index eb76107483..5e160d2372 100644 --- a/libraries/AP_HAL/utility/Print.cpp +++ b/libraries/AP_HAL/utility/Print.cpp @@ -30,7 +30,7 @@ using namespace AP_HAL; /* default implementation: may be overridden */ -size_t Print::write(const uint8_t *buffer, size_t size) +size_t Print::write_implementation(const uint8_t *buffer, size_t size) { size_t n = 0; while (size--) { diff --git a/libraries/AP_HAL/utility/Print.h b/libraries/AP_HAL/utility/Print.h index ddfb20a907..58812c0c3e 100644 --- a/libraries/AP_HAL/utility/Print.h +++ b/libraries/AP_HAL/utility/Print.h @@ -47,8 +47,9 @@ class AP_HAL::Print { virtual size_t write(uint8_t) = 0; size_t write(const char *str) { return write((const uint8_t *)str, strlen(str)); } - virtual size_t write(const uint8_t *buffer, size_t size); - + size_t write(const uint8_t *buffer, size_t size) {return write_implementation(buffer, size);} + virtual size_t write_implementation(const uint8_t *buffer, size_t size); + public: size_t print(const char[]); size_t print(char); size_t print(unsigned char, int = DEC);