On 09/30/2011 08:20 PM, Andrej Mitrovic wrote:
> I think this is a side-effect of the new function pointer fixes, where
> you now can't implicitly convert an extern(C) function to an extern(D)
> function by accident (and that's a good thing). But the problem is,
> you can't define a function with a different linkage type inline as a
> type parameter. You have to use an alias instead:
> 
> extern (C) int puts(const char* s);
> alias extern(C) int function(const char*) FunPtr;

<code golf>

template C_function(Ret,Params...){
   // Params shall not have modifiers, because C has no modifiers,
   // therefore this is good.
   alias extern(C) Ret function(Params) C_function;
}

void input_hook(C_function!(int) hook){
   ud_set_input_hook(&obj, hook);
}

</code golf>


I presume the extern(C) is transitively applied to e.g.

extern(C):
...

void ud_set_input_hook(ud*, int function(ud*));

Reply via email to