Re:Why I rewrote my Rust keyboard firmware in Zig: consisten...
by the_duke on Sunday March 07, 2021 @05:39AM
(#26374784)
Correct me if I'm wrong, but I don't think D has the ability to just import C headers and seamlessly use them without having generated or manually written `extern` declarations?
[ Parent
| on HN ]
Re:Why I rewrote my Rust keyboard firmware in Zig: consisten...
by lenkite on Sunday March 07, 2021 @07:09AM
(#26375257)
An extern declaration is needed.
https://dlang.org/spec/interfaceToC.html
https://dlang.org/spec/cpp_interface.html
C (or even C++) functions can be called directly from D. There is no need for wrapper functions, argument swizzling, and the C functions do not need to be put into a separate DLL.
I think Walter Bright achieved this via implementing a full-blown C++ parser in the dlang compiler. A [God-Tier] achievement.
Re:Why I rewrote my Rust keyboard firmware in Zig: consisten...
by chromatin on Sunday March 07, 2021 @08:59AM
(#26375862)
Not quite as seamless as Zig, but dstep is an external program that leverages libclang to do the same thing (and generates a D module for you), as well as e.g., smartly convert #define macros to inlineable templates functions :)
Re:Why I rewrote my Rust keyboard firmware in Zig: consisten...
by skocznymroczny on Monday March 08, 2021 @07:16AM
(#26384874)
Not by default. There is a project named dpp which adds such functionality though (never tried it).