Announcement

Collapse
No announcement yet.

Display.putstr("string") must be (char*)"string" in Arduino 1.6.8?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display.putstr("string") must be (char*)"string" in Arduino 1.6.8?

    I didn't see any search function for the forum and my google search did not come up with anything much. I am using the Goldelox graphics library for a uLCD-144G2 display and an Arduino Pro Mini. I had been using Arduino 1.0.6 with no errors or warnings, but with the latest 1.6.8 I got warnings like this:

    char* str;
    str = "OUTPUT V = \0";
    Display.putstr(str) ;
    warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    The following work to avoid the error:

    str = (char*)"INPUT V = \0";
    Display.putstr(str) ;

    as well as

    Display.putstr( (char*)" ") ;

    I also used the following to declare and optionally initialize the str variable:

    char str[17];

    Using the direct (char*) cast in the function seems to use the least amount of flash memory. I just want to be sure to prevent buffer overflow and memory corruption.

    Thanks.
    Last edited by PStechPaul; 3rd April 2016, 03:34 PM.

  • #2
    >> Using the direct (char*) cast in the function seems to use the least amount of flash memory.

    Exactly, that's Why you have to learn to ignore the silly warning message.

    As I understand it, someone somewhere has decided that string objects are 'the go' and that 'char *' should be deprecated, hence the message.

    As you have noticed 'string objects' are far hungrier on memory, than 'char *', so why on earth would you want to use them on hardware with such a small amount of memory?

    Mark

    Comment

    Working...
    X