Tuesday, January 25, 2011

So is any function passed as an argument a "callback function"?

Every time I see "callback function" mentioned in a tutorial or my book it has to do with function pointers and then passing the addresses as arguments. In GTK I'm not declaring my functions as anything other than vanilla function but I'm passing them as arguments.

Something on the to do list is figuring out how qsort works. Qsort requires an address to a function.

*EDIT*

I just realized that in GTK my g_signal_connect functions look like this:

g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (killwindow), NULL);

My callback function killwindow() isn't a function pointer, but G_CALLBACK(killwindow) is casting my killwindow() function to be void (*killwindow)(...).

http://library.gnome.org/devel/gobject/unstable/gobject-Closures.html#GCallback

No comments:

Post a Comment