Re: [gtk-list] Re: Passing a struct through a gtk_connect_signal
- From: Derek Simkowiak <dereks kd-dev com>
- To: Rafael Peregrino da Silva <rafael bmt4 kf tu-berlin de>
- cc: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Passing a struct through a gtk_connect_signal
- Date: Mon, 13 Mar 2000 12:52:27 -0800 (PST)
> Hi ALL :-)
Please continue this thread only on email@example.com, and stop
cc:ing firstname.lastname@example.org. Using these mailing lists would
quickly become impossible if every other discussion appeared in both
> I already knew the solution you gave me, but was wondering if there would
> not be a trick to avoid the global declaration/definition of a structured
> type, e.g., declaring the struct in main() as static or something like
I think there may have been some miscommunication. There is no
need to declare the pointer to your struct as global.
> Oualline/Practical C Programing)... By the way, I don't really see much
> difference between the definition of the struct as global (and then use
> the variables directly) and the definition of a structured type (with
> which I would then declare a new variable into main() and then pass it to
> my callback)...
There's a BIG difference, called "modularity". Global variables
should be avoided at all costs. Read chapter 18 of your "Practical C
Programming" book. Also, download a few (mature) Open Source projects and
examine the structure of their codebase.
Also, whether or not your structure is global, the function is
expecting a pointer, NOT a structure (of ANY type), so you MUST pass the
function a pointer and reference the variables like
...which is something you should get used to as soon as possible
anyhow. Much of Gtk+ (and any other well-designed library) is designed to
work that way.
] [Thread Prev