ImportC + -H = bindings

Kapendev alexandroskapretsos at gmail.com
Fri Apr 24 01:09:28 UTC 2026


I recently made a script/library called 
[Clonoa](https://github.com/Kapendev/clonoa) that generates D 
bindings from C files using ImportC.
The way it works is really simple:

1. Runs: `compiler -o- -H file.c`
2. Parses the `.di` file from the command above and prints a 
cleaned version of it to stdout.

The generated output tries to avoid some redefinitions of Libc 
symbols and it assumes that names starting with `_` are always 
private, so they get skipped.
Overall it does a good job of including the right things.
For example, I was able to create bindings for SDL2 and use them.

To use the script via DUB, you can run:

```
dub run clonoa
```

Or even simpler, copy-paste the script into your own project.
Clonoa is just one D file.


More information about the Digitalmars-d mailing list