IupSetCallback function passing
James Wirth
jwirth1 at suddenlink.net
Tue Mar 18 19:21:17 PDT 2014
When trying to associate an Icallback function to a button in the
IUP GUI
API using the IupSetCallback function, the D compiler seems to
insist on evaluating that callback in order to pass its value
rather than passing the function itself.
I get this dmd compiler error (the source is named hitmeiup.d) :
Error: function hitmeiup.hitMeAct (Ihandle_* dmy) is not callable
using argument types ()
hitmeiup.d(41): Error: expected 1 function arguments, not 0
for this line calling the IupSetCallback:
IupSetCallback(btn,"ACTION",hitMeAct);
The callback function was named hitMeAct as follows:
extern(C) {
int hitMeAct(Ihandle *dmy) {
sayHit();
return 0;
}
}
I have also tried it with hitMeAct being a D function instead of
extern(C).
It is as if the call to IupSetCallback is interpreting hitMeAct
to be a property function and that the call was meant to be:
IupSetCallback(btn,"ACTION",hitMeAct());
It there someway to force D to consider the hitMeAct parameter to
be passing a function and NOT calling it? I tried prefixing a &
- no go.
Would welcome any hints.
Yes I have already looked at the .d files purporting to provide
access to IUP.
And a more or less equivalent C program works fine.
More information about the Digitalmars-d
mailing list