Function pointer callback from C

Mike Johnson mrjohnson at
Sun Feb 25 22:50:39 PST 2007

I was having a lot of trouble getting the delegate declaration to work 
and dmd was saying something about not implicitly converting "void (C *) 

I didn't know how to declare a delegate with C conventions. When I added 
the extern(c), it works. I'm not sure I understand why yet.

Here's the error message without extern:
mainwindow.d(43): function gtk.gtkwidget.GtkWidget.connectSignal 
(char[],void delegate(int* widget, void* data),void*,GConnectFlags) does 
not match parameter types (char[11],void delegate(int* widget, void* 
mainwindow.d(44): Error: cannot implicitly convert expression 
(&this.on_toolNotebook_changePage) of type void delegate(int* widget, 
void* data) to void delegate(int* widget, void* data)

To my eyes, those types look the same. *shrugs*

Derek Parnell wrote:
> On Sun, 25 Feb 2007 22:12:51 -0800, Mike Johnson wrote:
>> The function doing black magic:
>>      extern(C) public void connectSignal(
>  . . .
>> The signal handler itself:
>>      private extern(C) void on_sv_changed(int *widget, int *data) {
> Why do you use "extern (C)" ?

More information about the Digitalmars-d-learn mailing list