Re: Compile warning (newbie)



On Tue, 2007-04-17 at 08:22 +1000, Andrew Cowie wrote:
> Return type of gtk_entry_get_text() is (const gchar*), not just
> (gchar*). You discarded the const qualifier when assigning the result to
> str.
> 
> Just declare str with const.

The reason why this is important is because gtk_entry_get_text is
returning you just a pointer to a buffer inside the widget.  Therefore
you should never modify it.  If you do, you run the risk of crashing the
program.  That's why the return type is const and the compiler gives you
a warning.

If you want to do something to the string you need to copy it with
g_strdup, remembering to free your copy when you are done.

Michael


> 
> AfC
> Sydney
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list




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