Re: gtk_entry_get_text() - having problems with return type
- From: Keith Sharp <kms passback co uk>
- To: Ben LeMasurier <uidzer0 hotmail com>
- Cc: Raymond Wan <rwan cs mu oz au>, gtk-list gnome org
- Subject: Re: gtk_entry_get_text() - having problems with return type
- Date: 05 Mar 2003 19:04:21 +0000
On Wed, 2003-03-05 at 01:16, Raymond Wan wrote:
> Hi,
>
> On Wed, 5 Mar 2003, Ben LeMasurier wrote:
> > warning: assignment makes pointer from integer without a cast
> >
> > gethostbyname() requests a char *
> > and gtk_entry_get_text() returns G_CONST_RETURN gchar*
>
> According to the glib docs, a G_CONST_RETURN gchar* is typedef'ed
> to a char* (See glib, basic types in the docs). But, as it stresses in
> the gtk_entry_get_text (), you shouldn'tfree, modify, or store it. I
> think I malloc'ed a temporary variable of type char * and did a strcpy and
> that worked fine. Just don't try storing it with an assignment...
What I normally do is use g_strdup (), eg:
gchar *name;
GtkWidget *name_entry;
name = g_strdup (gtk_entry_get_text(GTK_ENTRY(name_entry)));
g_print ("The name was: %s\n", name);
g_free (name);
Keith.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]