given somethign like Threads.threadsAddIdle

which takes an extern(C) int (void*)

we can't seem to do

threadsAddIdle((void*) { }, null);


because D complains is not the correct type nor can we do



extern(C) delegate(void*) {}

and have to resort to verbosity to get it to work. Is there a way around that? Why can't D realize that an inline lambda should use the same calling convention? There is no harm in doing so.

Maybe I'm doing it wrong:

I've tried

        import gdk.Threads;
                alias DD = static extern(C) int delegate(void*);
                auto x = (void*)
                        return 1;
                gdk.Threads.threadsAddIdle(x, null);

which gives the error

(extern (C) int function(void* userData) funct, void* data) is not callable using argument types int function(void* _param_0) pure nothrow @nogc @safe, typeof(null))

While one can do something like

gdk.Threads.threadsAddIdle(cast(GSourceFunc)(void* data)
                           return 1;
                           }, null);

which seems to work but the cast seems superfluous as D should be able to implicitly figure that out since it's an inline delegate.

Reply via email to