On 14/09/11 13:14, Russell Bryant wrote:
>>> >>> + ret = g_spawn_async(NULL,
(gchar **) k5start_bin,
>>> >>> NULL, G_SPAWN_SEARCH_PATH,
>>> >>> + NULL, NULL, NULL,&error);
>> >>
>> >> Just make the array non-const so you don't have to cast.
>> >>
> > Then I get string warning in c++ :\
> >
C++ is silly.
Nnnno...
Well, yes, but not because of this ;)
If you initialise something with literal strings like this
+ const gchar *k5start_bin[] = {
+ "/usr/bin/k5start",
+ "-f",
+ "/etc/krb5.keytab",
+ "-K",
+ "10",
+ "-U",
+ };
then the compiler is free to store them in a section that genuinely
_cannot_ be modified. If you then make the array non-const then it
really has to warn you.
What's silly is that g_spawn_async() takes an array of non-const
strings, even though it presumably has no need to modify them. I'm
guessing that part of the reason is that there is no automatic
conversion to const char** from char**, which is a consequence of the
(IMHO unfortunate) decision to treat const objects as entirely separate
types.
- ZB