Unknown cause of ISO C++ forbids converting a string constant to 'char*'

My project code was working perfectly fine before, but now it's randomly giving me this error for some unknown reason.

ISO C++ forbids converting a string constant to 'char*'

And it's giving me this error for every single instance of, for example: tft.drawCentreString or tft.drawRightString

So for pretty much any tft.function that is not exactly tft.print.

The TFT library I'm using is Bodmer/TFT_HX8357. The board I'm using is an Arduino Mega 2560 Rev3.

I've checked to make sure all of my libraries are installed and functioning properly (they are as far as I can tell). There is no prior error message to the string to char error messages either (it's the first one on the list and every single one after that). This error is preventing my user menu from being displayed on the TFT screen.

I ran my code through VS Code PlatformIO to check for coding errors and it is showing that there are none.

I'm not trying to convert a string to a character, so I'm completely baffled. What are some common causes of this problem? Any help would be appreciated. If more info is needed, please let me know. Unfortunately, I cannot upload the entire code to here because I'm under an NDA for it.

(deleted)

A string in this context is a literal string. Literal string is of the form:

char *s = "this is literal string";
SomeFunction("this is also literal string");

The content is literal string shouldn't be changed. That's why you get this error when you pass a literal string to a function that expects a char* (which can be changed)

To fix: mark your parameters as const.

spycatcher2k:
So this is a commercial project? If so, it's up to you to employ someone (Yes that does involve paying them) to do YOUR work that you are uncapable of doing!

It is a senior design university project.

(deleted)

arduino_new:
A string in this context is a literal string. Literal string is of the form:

char *s = "this is literal string";

SomeFunction("this is also literal string");




The content is literal string shouldn't be changed. That's why you get this error when you pass a literal string to a function that expects a char* (which can be changed)

To fix: mark your parameters as const.

Thanks for the tip arduino_new. I went into the library .h and .cpp files and modified the appropriate code. All of the errors are gone and everything is working perfectly now.

spycatcher2k:
Lecturing in University, I've never heard of an NDA put in place for an assignment!

Probably to try to get people to do their own homework instead of going to the forums to cheat.

randomly giving me this error

While its compiling? Sometimes it compiles ok and sometimes you get the error?

-or-

While its running. If then, where is the error message showing up?

-jim lee

The later version of the compiler has gotten a bit more sensitive to that type of warning. You are not the only one to see warnings show up for code that previously compiled with no problem, and that is not an error that prevents compilation, just a reminder that it is not strictly correct.

Worse than that. I get stuff that just won’t work at all. Type checking between derived classes seems to just stop things working as your calls go to the wrong classes.

Sigh… why?

-jim lee

jimLee:
Worse than that. I get stuff that just won't work at all. Type checking between derived classes seems to just stop things working as your calls go to the wrong classes.

Sigh.. why?

-jim lee

It is more believable that you write wrong code rather than the compiler wrongly accuses you of writing wrong code.

WHAT?! I'm being accused by my compiler?!

-jim lee