
How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC?
So I'm working on an exceedingly large codebase, and recently upgraded to gcc 4.3, which now triggers this warning:
> warning: deprecated conversion from string constant to ‘char*’
Obviously, the correct way to fix this is to find every declaration like
char *s = "constant string";
or function call like:
void foo(char *s);
foo("constant string");
and make them `const char` pointers. However, that would mean touching 564 files, minimum, which is not a task I wish to perform at this point in time. The problem right now is that I'm running with `-werror`, so I need some way to stifle these warnings. How can I do that?
More
1 Expert Answer

Patrick B. answered 06/24/20
Tutor
4.7
(31)
Math and computer tutor/teacher
type cast to (char *)
EX.
void DebugLog( char * debugMsg)
.....
DebugLog( (char *) " This is a test ");
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
global search and replace the function call adding the typecast (char *)06/24/20