Re: best way to pass data around



typedef struct Data_To_Be_Sent {
        GtkWidget *scrolled_window_data_to_be_sent;
        GtkTextBuffer *buffer;
        GtkWidget *view_data_to_be_sent;
        int sockfd;
} Data_To_Be_Sent;

My question is, is there a better way to do this? Is using a typedef struct a good idea? my grasp of C isn't so great. not that I don't know syntax it's just how to use that syntax sometimes and writing GTK really stretches the limits... I want to learn the best practices of course. :) any comments are welcome.

This is a good idea. Alternative you can define your own GObject.
But for this simple structure this is too much.

Tip: For debugging purpose I add an integer member "magic" with a
constant but random number assigned at initialization time. Every
time you cast the gpointer argument you test with a g_assertion for
this value. This is similar to the cast checks when using GObjects.

Cheers

Andy



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