The code below gives a warning during compilation of
warning: deprecated conversion from string constant to 'char*'
Is there another way to do the same avoiding this complaint by the compiler?
LogSDCard("NTP Syncronization Success",0,26,0);
bool LogSDCard(char *logData, byte Start, byte Len, byte time)
{
...
...
}
Thanks
bool LogSDCard(const char *logData, byte Start, byte Len, byte time)
gfvalvo:
bool LogSDCard(const char *logData, byte Start, byte Len, byte time)
ok.. but then how about this :
LogSDCard(ReplyBuffer,0,19,1);
system
April 24, 2018, 1:00pm
4
Is there another way to do the same avoiding this complaint by the compiler?
Yes. You have a string constant. I'll be you can find it. You are passing that string constant (who's type is const char *) to a function that expects a char *.
Make the string not const:
char whatToPrint[40];
strcpy(whatToPrint, "NTP Syncronization Success");
and print that:
LogSDCard(whatToPrint,0,26,0);
Use a cast:
LogSDCard((char *)"NTP Syncronization Success",0,26,0);
And this is best - Fix your function declaration:
bool LogSDCard(const char *logData, byte Start, byte Len, byte time)
system
April 24, 2018, 1:02pm
5
but then how about this :
What about it? If you make the function argument const, what that means is that the function guarantees not to change the pointed to data.
PaulS:
What about it? If you make the function argument const, what that means is that the function guarantees not to change the pointed to data.
Thanks PaulS for a comprehensive solution!