ImportC + -H = bindings

Lance Bachmeier no at spam.net
Fri Apr 24 13:52:48 UTC 2026


On Friday, 24 April 2026 at 02:56:31 UTC, Kapendev wrote:
> On Friday, 24 April 2026 at 02:09:00 UTC, Lance Bachmeier wrote:
>> I'm not sure how it compares to clonoa, but I let ImportC do 
>> the translation of C headers in their entirety using the -Hf 
>> switch. Now, that isn't going to generate .di files that work, 
>> but I have a program that parses the files to remove duplicate 
>> definitions, functions with keywords as names, and whatever 
>> else doesn't work. It's at the point that it can automatically 
>> convert any C header I try.
>
> It does the same thing! And yeah, by default the `.di` files 
> will not always work because of D keywords or of some other 
> weird translations like:
>
> ```
> alias void foo_func_type(...)
> ```
>
> The solution for this one is to change the order of things: 
> name first and then the function type.
> In general you have to clean the `.di` files.
>
> Here are some things that I can control with my script (some 
> options are not exposed in the CLI):
>
> ```d
> struct ClonoaArgs {
>     string compiler = defaultCompiler;
>     string headerPath;
>     string moduleName;
>     string[] headerIncludes;
>     string[] headerPrefixes;
>     string[] opaqueStructs;
>     bool removeRepeatedEnums;
>
>     string moduleSymbolHeader = defaultModuleSymbolHeader;
>     string indentation = defaultIndentation;
>     string[string] typeMap;
>     string[] typeSkipList;
>     string[] funcSkipList;
>     string[] lineSkipList;
> }
> ```

This would be a good addition to the compiler if the two of us 
working independently were able to solve the problem. In an 
alternative world where it's worth one's time to propose such 
things, it would make a great addition to the compiler.


More information about the Digitalmars-d mailing list