digitalmars.D.learn - Easy way for FFI
- Maximilian Naderer (12/12) Sep 22 Hello,
- Richard (Rikki) Andrew Cattermole (7/7) Sep 22 There are a number of solutions for C bindings creation.
- Maximilian Naderer (5/5) Sep 22 Hello Richard,
- Richard (Rikki) Andrew Cattermole (3/5) Sep 22 There is support in the compiler, but its not really mature.
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);
Sep 22
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.
Sep 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 ?
Sep 22
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[
Sep 22