Writing a Linux driver in the D ecosystem

welkam wwwelkam at gmail.com
Tue Oct 23 12:46:42 UTC 2018


On Tuesday, 23 October 2018 at 12:06:48 UTC, Eduard Staniloiu 
wrote:
> Hello, everyone!
>
> We, here at UPB, were thinking if it would be possible to write 
> a simple Linux driver.

Is it possible to write Linux driver in D? Yes.

If you want to call C code from D then its easy. 
https://dlang.org/spec/interfaceToC.html

If you want to call D code from C then it gets more tricky. 
Before C can use D code D runtime needs to be initialized by 
calling this function:
https://dlang.org/library/core/runtime/runtime.initialize.html

I am not familiar with driver architectures and dont know how 
convenient it is to add that init call but if its easy then what 
is left to do is to sprinkle your code with extern (c) and it 
should link and work. And if its not convenient then there is 
another option.

Writing D code without its runtime. There is a compiler flag 
-betterC that removes D runtime but you also loose all 
functionality that depends on runtimes. Now you can write C type 
libraries with subset of D. Here is article on that.
https://dlang.org/spec/betterc.html



More information about the Digitalmars-d mailing list