Re: types checking signal/callback functions revisited




Bil Wendling <wendling@ganymede.isdn.uiuc.edu> writes:

> I had a similar situation come up in a project I'm working on right now.
> Basically, using the pointer to the function
> 
> 	void callback(GtkWidget *, GtkWhatever *)
> 
> when the program expects you to use
> 
> 	void callback(GtkWidget *, gpointer)
> 
> is not a Good Thing (tm). They are two different types and there is no
> guarantee that the compiler will do the right thing with them. In other
> words, this may break on some platforms in undefined ways.

I'm pretty sure you are wrong about this - at least for all
platforms worth considering in the context of GTK+. The C standard
requires (if I remember correctly) that any pointer type will
survive a round-trip cast to a different pointer type.

You can get into trouble with alignment if you try to use
a pointer to one type as a pointer to a type of a different
alignment, and then try to use it that way. But that is
a different issue entirely.

Regards,
                                        Owen



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