On Tuesday, 30 March 2021 at 04:01:12 UTC, Brad wrote:
I would like to use an updated version of the Termbox library
(written in C) with D. I have the .h file. This is new
territory for me (why try something easy - right?). I think I
need to create a .di file that corresponds to the .h file. I
also suspect that I need to put the library file (C code) into
the project as a file somehow. I am probably just not looking
in the right place for the documentation, but I cannot seem to
find a lot of guidance in this area.
Thanks in advance.
Hi Brad
I used dstep https://code.dlang.org/packages/dstep to help me
with this process. Though I ended up checking the output and
fixing a couple oddities in the "extern (C):" line, it was *huge*
time saver.
The result was a D module file (i.e. thing.d, not thing.di) that
I could include like any other, so long as the C library was
specified on the compiler command line.
In addition, you might want to check out
https://wiki.dlang.org/Deimos where standard patterns are
discussed for D prototypes of C libraries. I ended up using the
command line:
dub init --format=deimos
to start off the wrapper lib package, then copied in the C
header, and then ran dstep.
Cheers,