Re: [gtk-list] Re: Passing a struct through a gtk_connect_signal

> Hi ALL :-)

	Please continue this thread only on, and stop
cc:ing  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
> that...

	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.


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