DLL, export bool dfunc(char[] s, extern (Windows) bool function() cb)

Bjoern nanali at nospam-wanadoo.fr
Tue Jan 15 13:55:41 PST 2008


Jarrett Billingsley schrieb:
> I'm guessing that 4GL expects DLL functions to use either C or Windows 
> calling conventions.  Secondly AFAIK there's no way to indicate the calling 
> convention of a function pointer inline; it has to be done as an 
> alias/typedef and then used.
> 
> alias extern(Windows) char[] function() MyFuncType;
> 
> // Don't know if it's extern(C) or extern(Windows)
> extern(Windows) export bool dfunc(char[] s, MyFuncType cb)
> {
>     ...
> } 

Thanks Jarret!,
yes the 4GL expects Windows calling convention. (and uses just the .DLL, 
no .LIB)
Using an alias instead of inlining is okay, not to say smarter!

In reality I have to use :

alias extern(Windows) void function(char[] token, bool eof) MyFuncType;

extern(Windows) export bool dfunc(char[] s, MyFuncType cb)
{
   // do something and call cb, (exists in a secondary thread)
  cb(token, false)
}
I hope this is correct ?

However, thanks to your help I should be able to solve the problem(s) :) 
by myself. Bjoern



More information about the Digitalmars-d mailing list