Jump to page: 1 2 3
Thread overview
importc and stb
Dec 16, 2021
stb
Dec 16, 2021
rikki cattermole
Dec 18, 2021
Walter Bright
Dec 16, 2021
Adam D Ruppe
Dec 16, 2021
Guillaume Piolat
Dec 16, 2021
Adam D Ruppe
Dec 16, 2021
Guillaume Piolat
Dec 16, 2021
Guillaume Piolat
Dec 18, 2021
Walter Bright
Dec 16, 2021
bachmeier
Dec 16, 2021
Elronnd
Dec 16, 2021
bachmeier
Dec 16, 2021
Abdulhaq
Dec 17, 2021
Patrick Schluter
Dec 18, 2021
Temtaime
Dec 16, 2021
bachmeier
Dec 16, 2021
bachmeier
Dec 19, 2021
bachmeier
Dec 18, 2021
Walter Bright
Dec 20, 2021
stb
Dec 20, 2021
Walter Bright
December 16, 2021

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.

December 16, 2021
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
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

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.

December 16, 2021

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?
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.

More STB translations:

  • stb_image.h v2.27
    => D translation
    I believe this is the fastest/resource efficient PNG loading available in D.
    That one is stripped for only PNG decoding only, it's useful if you want 16-bit PNG and the latest STB optimizations.

  • stb_image_resize.h v0.96:
    => D translation
    I believe this is the fastest/memory-aware image resizing available in D. It is an image resizer with an excellent quality.

  • stb_truetype.h v0.7:
    => D translation

  • stb_vorbis.h v1.22:
    => D translation

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
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
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
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
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

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?
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.

So over lunch I decided to take another look. I downloaded Ian's fixes as fixes.h and then did

gcc -E -P stb_ds.h > stb_ds_d.c
gcc -E -P -include fixes.h stb_ds_d.c > stb_ds_d2.c
ldmd2 -c stb_ds_d2.c

Compiled without any error messages or warnings.

« First   ‹ Prev
1 2 3