Re: GTK signals question.



On 03/05/14 12:07, Chris Vine wrote:
On Wed, 05 Mar 2014 09:44:48 -0500
Chris Moller <moller mollerware com> wrote:
I was actually writing that testcase when I found a correlation: I'm
using gcc and my callbacks were nested functions.  Pull the callbacks
out and make them normal, top-level, functions, and it all works even
without no blocking of any kind.  So, if this is a bug at all, I
suppose it could be a compiler bug.
Your question contained references to GTK+'s C interface.  If that
means that you are using C or C++ for your program, those languages do
not have a syntax for nested functions, so what you say does not really
make sense.  If you are simulating them in C++ using static methods of a
nested struct, in C++98 you have undefined behaviour if you try to use
them as a callback, because static member functions of classes with
local scope have no linkage (this follows because §3.5/5 of the standard
provides that a member function of class scope has external linkage if
the name of the class has external linkage, which it doesn't in the
case of local nested structs, and §3.5/8 provides that "Names not
covered by these rules have no linkage").

So it is most likely a misunderstanding on your part rather than a
compiler bug, but you would need to post your code to be sure.

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.


Chris






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