Fixes implementation of __FlashStringHelper (#183)

Previous __FlashStringHelper implementation was defines as a char which brought problem in case the method with char* parameter used overloading with __FlashStringHelper* parameter (they was identical). Now __FlashStringHelper is defined as a class and all casts between char* and __FlashStringHelper* are made with reinterpret_cast sugar.
This commit is contained in:
Martin Sloup
2017-02-08 18:57:26 +01:00
committed by Me No Dev
parent cea41d965a
commit 67128fcb2c
5 changed files with 35 additions and 59 deletions

View File

@ -68,19 +68,12 @@ size_t Print::printf(const char *format, ...)
}
return len;
}
/*
size_t Print::print(const __FlashStringHelper *ifsh) {
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
size_t n = 0;
while (1) {
uint8_t c = pgm_read_byte(p++);
if (c == 0) break;
n += write(c);
}
return n;
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
*/
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
@ -140,14 +133,14 @@ size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
/*
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
*/
size_t Print::print(const Printable& x)
{
return x.printTo(*this);