RE: Newbie question




it means that `msg' was declared as `const [something] * msg;'
and now that you are assigning something to it, the compiler must
discard `const'.

Or the other way around.
gtk_entry_get_text returns const char *, and msg is probably char *.
either declare const char *msg, or cast it 
msg = (char *) gtk_entry_get_text...

Thats a bad idea IMO.

This means:

a) you may potentially free it
b) the compiler will not warn you if you try to free it
c) your app is likely to go tits up when you free it.


You should simply use:

        G_CONST_RETURN gchar *str = NULL;

        str = gtk_entry_get_text(myentry);
        
        <use str somewhere>

I would suggest:


        G_CONST_RETURN gchar *entry_text = NULL;
        gchar *value = NULL;

        entry_text = gtk_entry_get_text(GTK_ENTRY(entry));

        value = g_strdup_printf("%s1", entry_text);
        gtk_entry_set_text(GTK_ENTRY(entry), value);

        g_free(value);  



Regards,
Martyn



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