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

Bjoern nanali at nospam-wanadoo.fr
Wed Jan 16 12:25:15 PST 2008


Jarrett Billingsley schrieb:
> "Bjoern" <nanali at nospam-wanadoo.fr> wrote in message 
> news:fmja4s$11rq$1 at digitalmars.com...
> 
>> 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 ?
> 
> That looks perfectly fine.  Only thing I wonder is, does 4GL support D-style 
> char[]?  Or will it be passing/expecting C-style zero-terminated char*? 
> 
> 
Thanks for confirming Jarret,

Yes it supports D style char with a little effort :

MyString is string  // dynamic ANSI string
MyUTF8String = StringToUTF8(MyString) // toUTF16 et vice versa

Heh, I still have to make  tests :)

But you are right, most probabely it is more economic to pass the string
as pointer to C string.
( because this string could contain the contents of an complete D source 
file ;) )
Due to the fact that my tool is garbage collection too, passing a string 
address (dynamic string)  and it's size , is not secure because this 
address may change. A dynamic string can contain 2 GB. here (in theory 
...), so using standard C string is most probabely what I have to 
choose. Let's see.

Bjoern
OT , in case that you are courious what 4GL I am using , here a link. 
You can download full working express copy . version 10, ( most current 
is 12) -- A 4GL + matrix - financial - statistic - array, dyn array, 
asso. array, runtime compiler,threads, outstanding GUI designer .... 
have fun.
http://www.windev.com/windev/quick-overview-WD.html





More information about the Digitalmars-d mailing list