Re: Compile warning (newbie)
- From: Michael L Torrie <torriem chem byu edu>
- To: gtk-list gnome org
- Subject: Re: Compile warning (newbie)
- Date: Mon, 16 Apr 2007 17:01:29 -0600
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]