Thread overview
September 22

Hello,
so what are my / our best options to create an automatic C foreign function interface.

I would like to create such interface / header file from a D module with public functions, structs which are declared with extern(C)

D code

module leo

extern(C) void test() { }

Expectation:

// header file
void leo_test(void);

September 23
There are a number of solutions for C bindings creation.

Try ImportC its built into the compiler.

You can use the .di generator to emit a D file for further use and manual cleanup.

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

It does depend upon the system toolchain, so you'll want MSVC installed if you use Windows.
September 22
Hello Richard,

Thank you for the info. I thought this goes the other way around. Using a header file and converting it to a .di file.

I want to create a .h file from my D modules so you’re saying this should be also possible ?
September 23
On 23/09/2024 10:13 AM, Maximilian Naderer wrote:
> I want to create a .h file from my D modules so you’re saying this should be also possible ?

There is support in the compiler, but its not really mature.

https://dlang.org/dmd-windows.html#switch-HC[