Best way to use large C library in D as of 2024

Chris Piker chris at hoopjump.com
Tue Mar 26 20:42:00 UTC 2024


On Tuesday, 26 March 2024 at 20:19:27 UTC, bachmeier wrote:
>
> Should be able to just use it, as described here: 
> https://forum.dlang.org/post/qxctappnigkwvaqakeqf@forum.dlang.org Create a .c file that includes the header files and then call the functions you need.

Wow. **That just worked the first time!**  Holy &^@$ that's easy!

So why does the 2nd page returned from the google search
```
interfacing with C site:dlang.org
```
(which happens to be: https://dlang.org/spec/interfaceToC.html) 
still have this text:

> Since D can call C code directly, it can also call any C 
> library functions,
> giving D access to the smorgasbord of existing C libraries. To 
> do so, however,
> one needs to write a D interface (.di) file, which is a 
> translation of the C .h
> header file for the C library into D.
> 
> For popular C libraries, the first place to look for the 
> corresponding D interface
> file is the Deimos Project. If it isn't there already, please 
> write and contribute
> one to the Deimos Project.
?

This lead me to believe that interfacing was a chore and I was 
considering going back to C for a small program I need.


More information about the Digitalmars-d-learn mailing list