Re: Problem with "warning: deprecated conversion from string constant to ‘char*’"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/10/12 Marc Glisse <marc.glisse@xxxxxxxx>:
> On Tue, 12 Oct 2010, Ian Lance Taylor wrote:
>
>> I'm not sure what you want us to suggest.  You say that the names are
>> modifiable.  String constants are not modifiable.  If the strings are
>> indeed modified, and you pass in a string constant, then your program is
>> going to crash when the library tries to modify the strings.  The gcc
>> warning is helpfully pointing that out.
>>
>> This is not a gcc issue.  It's a C++ language issue.  If you need a
>> modifiable string, then you must not use a string constant.
>
> I am not sure what the OP is asking for, but note that some other compilers
> provide an option (-features=no%conststrings for sunCC) to handle such
> broken legacy code without modification.

gcc provides -Wno-write-strings - but I like the warning in general and don't
want dumb disable it ;)
Probably there is no better way - but knowing how to modify the legacy
code to avoid the warning is a better way.

/Jens



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux