Re: Threads & Glade



On Mon, Oct 10, 2005 at 04:52:48AM -0700, lucapetra (sent by Nabble.com) wrote:

Now i have another question. How can I cast a gpointer to a struct?
It seems to be very hard to do :(

Not really:

struct foo orig;
gpointer gptr = (gpointer) &foo; // gpointer from pointer-to-struct
struct foo *fptr = (struct foo *) gptr // pointer-to-struct from
                                       // gpointer.
Now to get the struct back, just dereference the pointer (*fptr).

Remember that "gpointer" is just "void *".

Regards,
Roger

-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.



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