Using C header libs with importC

Renato renato at athaydes.com
Mon Jan 8 18:53:47 UTC 2024


Is it possible to use C header-only libs from D?

In C, I would need to do this:

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

The definition must be done in a single C file before including 
the h file.

I tried this in D:

```d
enum STB_DS_IMPLEMENTATION = 1;
import stb_ds;
```

But it doesn't work. Any suggestions? Perhaps using an 
intermediate C file to do this would work, but I wanted to know 
if D can do it.


More information about the Digitalmars-d-learn mailing list