newbie: callback function



Hi,

with msvc6.0 I had no problems but mingw/gcc gives me the following
error in the function call gtk_box_pack_start (see below): "invalid
conversion from'void(*)()' to'void*'. The problem is the function
pointer "callback_init" which gcc doesn't accept this way. But what's
wrong?

Felix



my callback:
------------

void callback_init() { /* ... */ }


my button create function (not quite important here):
-----------------------------------------------------

GtkButton *button_create(
        const char *text,
        void *callbackfunction)
{
        GtkWidget *gtkwidget1;
        gtkwidget1 = gtk_button_new_with_label(text);
        g_signal_connect(
                G_OBJECT(gtkwidget1),
                "clicked",
                G_CALLBACK(callbackfunction),
                NULL);
        gtk_widget_show(gtkwidget1);
        return GTK_BUTTON(gtkwidget1);
}


the main with the function which causes the error (see description):
-------------------------------------------------------------------

int main( /*...*/ ){

/*...*/

gtk_box_pack_start(
        GTK_BOX(hbox2),
        GTK_WIDGET(
                button_create(
                        "My Button Name",
                        callback_init   /* error */
                )
        ),
        INT_EXPAND,
        cgboolean_fill,
        cint_padding
        );


/*...*/

}



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