Using C header libs with importC

Dennis dkorpel at gmail.com
Mon Jan 8 21:04:10 UTC 2024


On Monday, 8 January 2024 at 18:53:47 UTC, Renato wrote:
> Perhaps using an intermediate C file to do this would work, but 
> I wanted to know if D can do it.

Yes, your best options are either:

- rename the .h to .c and edit it so the `STB_DS_IMPLEMENTATION` 
check passes or is removed.
- create a C file with what you already wrote:

> ```c
> #define STB_DS_IMPLEMENTATION
> #include "stb_ds.h"
> ```

And import that.

Importing .h files from d files isn't supported yet because of a 
dispute with the lookup priority:

https://issues.dlang.org/show_bug.cgi?id=23479
https://issues.dlang.org/show_bug.cgi?id=23547


More information about the Digitalmars-d-learn mailing list