Friday, October 28, 2022

[SOLVED] How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC

Issue

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?


Solution

I believe passing -Wno-write-strings to GCC will suppress this warning.



Answered By - DGentry
Answer Checked By - Marilyn (WPSolving Volunteer)