Re: Compile warning (newbie)

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

 



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@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux