Jens Rehsack <rehsack@xxxxxxxxxxxxxx> writes: > I currently write some c++ code using libConfuse > (http://savannah.nongnu.org/projects/confuse/). > During initialisation of the required cfg_opt_t structures I get a > (very) lot of warnings like: > c2.cpp:11: warning: deprecated conversion from string constant to âchar*' > > I attached a small example to demonstrate the problem. It's not > trivial - changing the "name" member > of struct demo being const, free failes (and is invalid, because > there're demo_opt instances with > modifyable names). > > Any suggestions welcome. > 1) Killing the warning with -Wno-... is not an option > 2) Remove the finding using const_cast<char *>() is the same as (1) > 3) initializing the struct using strdup is neither reasonable 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. Ian