Create C header files from

Lance Bachmeier no at spam.net
Mon Feb 16 20:04:36 UTC 2026


On Monday, 16 February 2026 at 17:07:53 UTC, MaxNaderer wrote:
> Hello guys,
>
> so how do we generate C header files automatically for a 
> library compiled with dmd, ldc
> in betterC. Like basic example below. I found the "-HC" flag 
> which can be used to output C++ header files. Do I need to 
> convert those manually to C?
>
> ```D
>
> export extern(C) {
>
>     uint add(uint a, uint b) {
>         return a + b;
>     }
>
> }

```
dmd -c mycode.c -Hf=mycode.di
```

https://dlang.org/spec/importc.html#ctod

If you want to output the function bodies as D code, add 
`-inline`:

```
dmd -c mycode.c -inline -Hf=mycode.di
```


More information about the Digitalmars-d-learn mailing list