D modules referenced by C source?
Robert Fraser
fraserofthenight at gmail.com
Wed May 6 16:43:26 PDT 2009
BCS wrote:
> Reply to Matt,
>
>> 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 "
>>
>
> The best approach might be to write a .h file with only the constants in
> it and then use htod to convert it into a .d header. Aside from that you
> would end up hand editing bith files.
>
>
If the constants are in a syntax recognized by both C and D (e.x.
they're just integers, or enums), you can write the .h and use D's
mixin(import("constants.h")), which would prevent you from having to
maintain two files.
If you're using some types differently in each, or want to use #defines
on the C side, etc., you could use CTFE to convert (there was a CTFE
regex engine floating around somewhere a whiel back... Actually, I'd
like to get my hands on that myself if anyone has the link).
More information about the Digitalmars-d
mailing list