#include C headers in D code
Atila Neves
atila.neves at gmail.com
Mon Apr 16 15:00:30 UTC 2018
On Monday, 16 April 2018 at 12:26:12 UTC, Jacob Carlborg wrote:
> On Monday, 16 April 2018 at 11:20:51 UTC, Atila Neves wrote:
>
>> You can use the C macros in the headers that you #include in
>> your dpp file.
>>
>> dstep has a lot of code for translating macros. I don't want
>> to translate macros at all, but it's deeply intertwined with
>> translating everything else.
>
> There's a command line switch to disable that,
> `--translate-macros=false`. Or, alternatively, run the
> preprocessor first.
I missed that.
>
>> I can't remember the specifics, but dstep by default ignores
>> declarations from other headers because the idea is to
>> translate this one particular header.
>
> That's a simple change: replace these lines [1] with `return
> false;`. If that's something you need we can make it
> configurable.
>
> [1]
> https://github.com/jacob-carlborg/dstep/blob/97870ac5167f09e8acf17f8754c32636492b237f/dstep/translator/Translator.d#L326-L329
No need to make it configureable now - I did the translation work
already and made a point of copying in dstep's tests to guarantee
the same level of support. Given how small it ended up being, I'd
trade ~500SLOC over a dependency nearly every time.
I also like the end result better (unsurprising since I wrote
it), even though I didn't quite achieve the level of testability
I wanted.
More information about the Digitalmars-d-announce
mailing list