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

Re: newbie: callback function



your prototype here is:

GtkButton *button_create(const char *text, void *callbackfunction)

if you were passing a void * pointer, that would be fine, but you're not.  you want something like this:

GtkButton *button_create(const char *text, void (*callbackfunction)())

because you're passing it a function pointer with a specified signature, not just a void * pointer.

	-brian


F. Kater wrote:

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
	);


/*...*/

}
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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