Skip to content
Prev Previous commit
Next Next commit
fix
  • Loading branch information
d-a-v committed Feb 19, 2020
commit 390ca30a476c2e080fb5058d1df40a61d3686912
25 changes: 14 additions & 11 deletions cores/esp8266/core_esp8266_noniso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ char* ultoa(unsigned long value, char* result, int base) {
return utoa((unsigned int)value, result, base);
}

char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
if (!_printf_float) {
return __dtostrf(number, width, prec, s);
} else {
char fmt[32];
sprintf(fmt, "%%%d.%df", width, prec);
sprintf(s, fmt, number);
return s;
}
}

static char * __dtostrf(double number, signed char width, unsigned char prec, char *s) {
bool negative = false;

Expand Down Expand Up @@ -129,4 +118,18 @@ static char * __dtostrf(double number, signed char width, unsigned char prec, ch
return s;
}

// extern weak declaration (= function pointer) to check whether _printf_float is defined
extern int _printf_float () __attribute__((__weak__));

char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
if (!_printf_float) {
return __dtostrf(number, width, prec, s);
} else {
char fmt[32];
sprintf(fmt, "%%%d.%df", width, prec);
sprintf(s, fmt, number);
return s;
}
}

};