Re: GTK signals question.



On Thu, Mar 6, 2014 at 5:43 AM, Chris Moller <moller mollerware com> wrote:
gcc supports nested functions as an extension to standard C.  I tend to use
them a lot because they operate within the stack frame of the enclosing
function, thereby minimising the amount of information you have to pass.
This is especially valuable in GTK callbacks where you can only pass one
pointer/int.

That's a nice idea as long as you don't let the calling function
return. As far as I know, gcc nested functions don't in any way "hold
onto" the outer state, so there'll be a pile of segfaults waiting for
you if the outer function has returned - like returning a pointer to
an automatic variable.

Is there a reason you're trying to write high-level code in C? Give
Python or Pike a shot - both have GTK bindings and are way WAY easier
to write code in. Believe me, I've written plenty of C code (including
GUI handling), and life is just so much better when memory management
isn't part of your daily keyboarding regimen.

ChrisA
PS. Has anyone else noticed that this thread is more than half by
people named Chris?


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