Re: GdkColor weird type? Why not pointer like GtkWidget*....



Am Die, 2002-04-23 um 00.37 schrieb Christian Seberino:
> 
> Thanks for reply.  You seem to know your stuff.
> If pointers are more complicated and unnecessary sometimes,
> then why does GTK+ have so many pointers? 
> Why are many things of GtkWidget* type and not GtkWidget?

The #1 reason is exactly what Paul said.  Other reasons are that you
cannot copy a GtkWidget (at least in a way that would make sense), and
generally to gain flexibility.  Also, pointers allow for hidden struct
definitions.

> It seems like GdkColor is the first widget I found that
> is not declared to be a pointer in sample code I found.
> 
> If this structures elements were *not* integers than then
> suggested initialization "= {0, 0, 0, 0}" would not work right?
> I'd have to replace those 4 zeroes with whatever type the struc
> held right?

Yes, but better would be "= { 0, }".   Note that the trailing comma
isn't a typo, it tells the compiler to initialize the remaining struct
fields as well.  0 will also work for pointer types, thus it probably
covers almost all plain structs used within GTK+.

--Daniel




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