importc and stb

bachmeier no at spam.net
Thu Dec 16 14:26:42 UTC 2021


On Thursday, 16 December 2021 at 10:38:38 UTC, stb wrote:
> are we going to be able use https://github.com/nothings/stb 
> with importc?
> these are header only libraries and i use stb (and similar 
> libraries) all the time.
> there is no reason for me to use c/c++ for tools if importc can 
> pull this off.

I just tried the first three files: stb_c_lexer.h, stb_divide.h 
and stb_ds.h.

The first two compiled without issues:

```
gcc -E -P stb_c_lexer.h > stb_c_lexer_d.c
ldmd2 -c stb_c_lexer_d.c
gcc -E -P stb_divide.h > stb_divide_d.c
ldmd2 -c stb_divide_d.c
```

The last gave errors:

```
gcc -E -P stb_ds.h > stb_ds_d.c
ldmd2 -c stb_ds_d.c
```

The errors are due to the insertion of stuff in the preprocessing 
step that's not C11. There are solutions for some of these (such 
as 
https://github.com/ibuclaw/importC/blob/main/src/keywords.c.in) 
but I didn't dig into it any further, since I have never used 
those libraries. The first error that comes up is due to 
`__restrict` rather than plain `restrict`.


More information about the Digitalmars-d mailing list