janet-lang / janet-lang.org

Website for janet
https://janet-lang.org
MIT License
90 stars 59 forks source link

Fix FFI section: corresponding C type name #199

Closed iacore closed 5 months ago

sogaiu commented 1 year ago

I don't understand the details very well, but I'm curious why ptrdiff_t and not ssize_t.

Something in here, perhaps?

iacore commented 1 year ago

ssize_t is not in the C standard. I've not seen it in C codebase before.

https://en.cppreference.com/w/c/types

sogaiu commented 1 year ago

That sounds similar to the following from the mailing list post:

  1. ptrdiff_t is more ubiquitous and better-standardized than ssize_t, as ptrdiff_t is required by the C standard whereas ssize_t is required only by POSIX.

I wonder if it doesn't make sense for ffi.c to use :ptrdiff instead of :ssize then...

@tr{@td{@code`:ptrdiff`} @td{ptrdiff_t}}
iacore commented 1 year ago

I wonder if it doesn't make sense for ffi.c to use :ptrdiff instead of :ssize then...

@tr{@td{@code`:ptrdiff`} @td{ptrdiff_t}}

We can support both :ptrdiff and :ssize (backwards compatible).

sogaiu commented 1 year ago

Ah, there's an idea :)

iacore commented 1 year ago

Question: why is float r32 not f32? Also, maybe the better name is usize and ssize. Rust and LLVM uses isize.

sogaiu commented 1 year ago

Question: why is float r32 not f32?

Wondered the same.

Looking at my QWERTY keyboard, I see r is quite close to f...but then I came across this.