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.
Thread overview | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 16, 2021 importc and stb | ||||
---|---|---|---|---|
| ||||
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to stb | In theory. Recently Iain let me know that zlib's test suite is now passing with ImportC. So the things that are missing are the macro preprocessor and whatever extensions those files use. Once they have been sorted out (the macro preprocessor is the big one of the two), then sure, they should work, if not either it isn't C or its a bug. |
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to stb | 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. note that some of these have already been ported to D like https://github.com/adamdruppe/arsd/blob/master/ttf.d though i haven't updated it back from upstream for a while. but i think the import C should work with those if you can set up the macros in a separate file ahead of time. |
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to stb | 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? I just tried the first three files: stb_c_lexer.h, stb_divide.h and stb_ds.h. The first two compiled without issues:
The last gave errors:
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 |
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D Ruppe | On Thursday, 16 December 2021 at 13:38:06 UTC, Adam D Ruppe wrote: >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? note that some of these have already been ported to D like though i haven't updated it back from upstream for a while. but i think the import C should work with those if you can set up the macros in a separate file ahead of time. More STB translations:
Most of the translations can't be used as-is in our codebase anyway, so they were all tweaked to fit their D purpose (eg: original might have ARM intrinsics). |
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to Guillaume Piolat | On Thursday, 16 December 2021 at 16:04:34 UTC, Guillaume Piolat wrote: > - `stb_image_resize.h` v0.96: I might just steal that from you my image resizer has nice quality but is awfully slow... > - `stb_truetype.h` v0.7: But you might want to steal my truetype thing cuz i have a much newer version than you do. > - `stb_vorbis.h` v1.22: hah my stb_vorbis is 1.10 so maybe i'll take yours. though i've done bug fixes to mine.... come to think of it i think we worked on this together before, the bugfix was upstream, you updated and i just cherry picked it. |
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D Ruppe | On Thursday, 16 December 2021 at 16:47:00 UTC, Adam D Ruppe wrote:
>> - `stb_truetype.h` v0.7:
>
> But you might want to steal my truetype thing cuz i have a much newer version than you do.
Yup! STB do receive improvements over time for example more recent stb_image had faster PNG loading. It could be nice if stb_truetype has eg. better antialiasing.
|
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to Guillaume Piolat | On Thursday, 16 December 2021 at 17:03:30 UTC, Guillaume Piolat wrote:
> On Thursday, 16 December 2021 at 16:47:00 UTC, Adam D Ruppe wrote:
>>> - `stb_truetype.h` v0.7:
>>
>> But you might want to steal my truetype thing cuz i have a much newer version than you do.
>
> Yup! STB do receive improvements over time for example more recent stb_image had faster PNG loading. It could be nice if stb_truetype has eg. better antialiasing.
So: another future win for ImportC! It is already receiving lots of attention for a new feature.
|
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to bachmeier | On Thursday, 16 December 2021 at 14:26:42 UTC, bachmeier wrote: > https://github.com/ibuclaw/importC/blob/main/src/keywords.c.in > #define __builtin_bswap16(x) ((u_int16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) Oh, my, that's bad. GCC __builtins don't generally evaluate more than once. And this could just be an inline function anyway. |
December 16, 2021 Re: importc and stb | ||||
---|---|---|---|---|
| ||||
Posted in reply to bachmeier | On Thursday, 16 December 2021 at 14:26:42 UTC, bachmeier wrote: >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? I just tried the first three files: stb_c_lexer.h, stb_divide.h and stb_ds.h. The first two compiled without issues:
The last gave errors:
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 So over lunch I decided to take another look. I downloaded Ian's fixes as fixes.h and then did
Compiled without any error messages or warnings. |