Creating a .di file for a custom C library

Ferhat Kurtulmuş aferust at gmail.com
Tue Mar 30 08:26:34 UTC 2021


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.

I never needed or used .di files. Dstep[1] can create d modules 
containing c header definitions. Recently, I used to create a d 
binding [2] for shapelib[3]. I just added "module shapelib;" at 
the beginning of the file, nothing else. Some c headers may 
require extra steps IMO.


1: https://github.com/jacob-carlborg/dstep
2: https://github.com/aferust/shapelib-d/blob/main/shapelib.d
3: https://github.com/OSGeo/shapelib



More information about the Digitalmars-d-learn mailing list