How to convert C to D using compiler?

bachmeier no at spam.net
Tue Dec 7 20:37:12 UTC 2021


On Tuesday, 7 December 2021 at 16:52:47 UTC, ManKey wrote:
> On Tuesday, 7 December 2021 at 16:49:58 UTC, 12345swordy wrote:
>> On Tuesday, 7 December 2021 at 16:43:21 UTC, ManKey wrote:
>>> I tried this
>>> ```
>>> ldc2 test.i -mixin="test.d"
>>> ```
>>> but the test.d file is empty :(
>>
>> https://dlang.org/spec/importc.html
>
> I just want to convert from C file to D file, don't import it

There's no way to convert arbitrary C files to D, but:

- You can compile C files directly if they are C11-compatible. 
You include them on the command line like .d files and import 
them the same as D modules. You have to run the C files through 
the preprocessor manually. There's not much support for GCC 
extensions.
- You can convert header files using 
[dstep](https://github.com/jacob-carlborg/dstep).
- You can include C header files directly in D modules using 
[dpp](https://github.com/atilaneves/dpp).


More information about the Digitalmars-d mailing list