Re:Moving forward with work on the D language and foundation
by dbaupp on Friday August 28, 2015 @08:39PM
(#10138533)
It seems Rust and D have very very similar C FFIs, see http://doc.rust-lang.org/book/ffi.html .
https://github.com/crabtw/rust-bindgen is a tool in the vein of dstep.
(Rust has the advantage of having no runtime beyond what C needs unlike D with its current garbage collector, so FFI, especially exposing a C interface, is likely somewhat simpler.)
Re:Moving forward with work on the D language and foundation
by rlonstein on Friday August 28, 2015 @01:26PM
(#10136732)
I can. I've written D interfaces to vendor-supplied C and C++ SDKs and for an open source C library (libusb). We're using this at work. For C, it's relatively easy and mechanical to translate by hand but https://github.com/jacob-carlborg/dstep makes starting trivial. For C++, I had two cases- one was easy as that vendor provided a C handle and function call syntax while the other required doing a C shim (facade) to wrap up the object. I didn't find SWIG to be useful but did examine its output to get ideas. The built-in unit testing in D is very handy.
http://dlang.org/interfaceToC.html
Can anyone comment further?