[Qt-interest] Why do I get a deprecated conversion warning about string to char*?

Matthias Pospiech matthias.pospiech at gmx.de
Tue Aug 10 15:20:53 CEST 2010


Thiago Macieira schrieb:
> Em Terça-feira 10 Agosto 2010, às 14:27:18, Matthias Pospiech escreveu:
>   
>> I get this waring everytime I use a char string in the code:
>> warning: deprecated conversion from string constant to 'char*'
>>
>> The code looks like this:
>>
>> sendCommand("BF");
>>
>>     
> ...
> The above code doesn't produce this warning.
>
> The code below however does:
>
> 	char *foo = "Hello";
>
> Solution: add const:
>
> 	const char *foo = "Hello";
>   
I know. However the compiler (mingw, Qt SDK) really shows this warning 
at each line where I call 'sendCommand'
Since this happens about 20x in the code I see this warning quite a lot...

Matthias




More information about the Qt-interest-old mailing list