D modules referenced by C source?

Robert Fraser fraserofthenight at gmail.com
Thu May 7 21:56:30 PDT 2009


Matt wrote:
> Denis Koroskin Wrote:
> 
>> On Thu, 07 May 2009 03:02:16 +0400, Matt <webwraith at fastmail.fm> wrote:
>>
>>> Hi, I apologise if this has already been asked, but I haven't gone and  
>>> DLed a news reader yet, so Firefox keeps complaining every time I try to  
>>> use the search box.
>>>
>>> I was planning to include some C source into a D project, and was  
>>> happily writing the D module for the "header" for the source, when I ran  
>>> into a little problem. I want to include some const values in the  
>>> module, which made me realize I don't know how to include the module in  
>>> the C source. I can see how it would work from the D side of the  
>>> compilation, but how would I go about making the const values visible to  
>>> the C code? Do I just #include "d_module.d"? Or is there a different way  
>>> to do this? What would the compilation process look like for this?
>>>
>>> Thank you in advance for any help you can provide.
>> Did you try htod? http://www.digitalmars.com/d/2.0/htod.html
>> There is also BCD http://www.dsource.org/projects/bcd
>>
>> Try both tools and let us know if it helped.
>>
> 
> Thanks, but the problem isn't with my writing the D module for C. It's how the C source imports that module to access the constants in it.

Well, if you write the constants in C, you can have them automatically 
translated to D in the build process and then just include the result.



More information about the Digitalmars-d mailing list