digitalmars.D.learn - D dll called from other lang app
- novice2 (13/13) Jul 22 2007 Hello.
- Jarrett Billingsley (9/24) Jul 22 2007 Have a look at http://www.digitalmars.com/d/dll.html, especially the "DL...
Hello. Sorry for dumb question. I need to write dll (as plugin for app written on C). And i want to do it with D instead of C. Is it possible? I can't imagine how garbage collect works, so i am afraid: can i use D dinamic arrays? can i use slicing? can i return D char[] to outside from dll? will GC work or i must care about memory myself? Are there any advises or general recomendations about this? (i already read http://www.prowiki.org/wiki4d/wiki.cgi?BestPractices/DLL, and it explain me about type system only) If this already explained then give me link please. Thanx
Jul 22 2007
"novice2" <sorry noem.ail> wrote in message news:f7v5gi$2rrr$1 digitalmars.com...Hello. Sorry for dumb question. I need to write dll (as plugin for app written on C). And i want to do it with D instead of C. Is it possible? I can't imagine how garbage collect works, so i am afraid: can i use D dinamic arrays? can i use slicing? can i return D char[] to outside from dll? will GC work or i must care about memory myself? Are there any advises or general recomendations about this? (i already read http://www.prowiki.org/wiki4d/wiki.cgi?BestPractices/DLL, and it explain me about type system only) If this already explained then give me link please. ThanxHave a look at http://www.digitalmars.com/d/dll.html, especially the "DLLs with a C interface" section and the "Memory Allocation" section. Probably the most important point on that list is " Retain a pointer to the data within the D DLL so the GC will not free it." Basically you can return a char[] to the other language so long as (1) you keep a reference to that data inside your DLL before returning it, and (2) the other code does not try to free()/delete that data.
Jul 22 2007