This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: deprecated conversion from string constant to 'char *'

Ian Lance Taylor wrote:
"Timothy C Prince" <> writes:

g++ 4.2 rejects a quoted string constant, where the function prototype has char *. It says warning, but the warning is fatal, even without -Werror. -fpermissive doesn't let it pass.

info g++ lists an option -fconst-strings, but that option has been removed.

What is expected as a replacement for current source code with 1000's of string constants, which up to now worked with char * prototype?

This is what I get:

extern void foo(char*);
void bar() { foo("Hello"); }
g++ -c In function ‘void bar()’: warning: deprecated conversion from string constant to ‘char*’'
echo $?

Looks like a warning to me, not an error.  Please give a small source
code example and the command line you are using.


Even in your example, gcc stops without making a .o file.  I did find
that correcting __all__ the relevant prototypes to 'const char *' fixed
my problem.  I had missed one tucked away in a long list.
Another compiler which I use frequently, which claims a high degree of
gcc compatibility, is unable to produce any warning.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]