calling from C into D

Chad J chadjoan at __spam.is.bad__gmail.com
Fri Aug 7 12:25:45 PDT 2009


BCS wrote:
> Reply to Aaron,
> 
>> Ok, next question:  If I wanted to run some D stuff under
>> the Apache web server in embedded mode I would have to
>> be able to write some C code which calls into D code.
>> This topic is not discussed in the docs that I can find.
>> Is it possible to call from C into D (to embedded D code into a larger
>> process written in C)?  You can't do this in java and this is one of
>> the reasons I always was averse to java from the beginning.
>>
>> Thanks again, -- Aaron Watters
>>
> 
> you need to create the header files by hand but you can call from C code
> to D functions that are extern(C).
> 
> 

You may also want to initialize the D runtime.

An example of that for D2 can be found here:
http://www.digitalmars.com/d/2.0/windows.html

or for D1:
http://www.digitalmars.com/d/1.0/windows.html

Even though you aren't writing a Windows application, you should
probably write some kind of "extern(C) init() {...}" function that your
Apache code would call and thus set up the runtime.



More information about the Digitalmars-d mailing list