error: 'fcvt' was not declared in this scope, when copiling the dtostrf

HI,

I got an issue, when I did compile a project on my mac with the function "dtostrf" it did work, now I swithced to a windows PC and now I get this error.

/tmp/713292119/sketch_sep21a/sketch_sep21a.ino: In function 'char* dtostrf(double, int, unsigned int, char*)':

/tmp/713292119/sketch_sep21a/sketch_sep21a.ino:30:7: error: 'fcvt' was not declared in this scope

exit status 1

Has anyone an idea why that happen? I tride yesterday to set up the arduino on an raspberry and there I got the same issu.

Thanks.

this is the code which I use:

/*

*/

#include <string.h>
#include <stdlib.h>
#include <math.h>

void setup() {

}

void loop() {

}

#if 0
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
char fmt[20];
sprintf(fmt, "%%%d.%df", width, prec);
sprintf(sout, fmt, val);
return sout;
}
#else
char *dtostrf(double val, int width, unsigned int prec, char *sout)
{
int decpt, sign, reqd, pad;
const char *s, *e;
char *p;
s = fcvt(val, prec, &decpt, &sign);
if (prec == 0 && decpt == 0) {
s = (*s < '5') ? "0" : "1";
reqd = 1;
} else {
reqd = strlen(s);
if (reqd > decpt) reqd++;
if (decpt == 0) reqd++;
}
if (sign) reqd++;
p = sout;
e = p + reqd;
pad = width - reqd;
if (pad > 0) {
e += pad;
while (pad-- > 0) *p++ = ' ';
}
if (sign) *p++ = '-';
if (decpt <= 0 && prec > 0) {
*p++ = '0';
*p++ = '.';
e++;
while ( decpt < 0 ) {
decpt++;
*p++ = '0';
}
}
while (p < e) {
*p++ = *s++;
if (p == e) break;
if (--decpt == 0) *p++ = '.';
}
if (width < 0) {
pad = (reqd + width) * -1;
while (pad-- > 0) *p++ = ' ';
}
*p = 0;
return sout;
}
#endif

So where is fcvt declared ?

Please follow the advice on posting code in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here

The problem is there is no fcvt function defined or declared.

Which board are you compiling for? dtostrf() is already defined for many arduinos, and generally sprintf does not support floats.