Le 05/03/2014 19:43, Chris Moller a écrit :
> [...]
> 
> 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.

Well, yes, but beware: the parent function's stack is not valid if the
parent function exited.  So for asynchronous callbacks, you can only use
it in the function managing the loop (e.g. main).  Otherwise they will
be called after the parent function exited, and so any access you do on
its stack will only lead to a crash in the best case.

In short, they are nested functions, but *not* closures.

Regards,
Colomban
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to